Changeset 455
- Timestamp:
- 04/02/07 23:54:13 (1 year ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/main/php/net/stubbles/reflection/annotations/parser/state/stubAnnotationParamNameState.php
r454 r455 67 67 if (strlen($this->name) == 0) { 68 68 throw new ReflectionException('Annotation parameter name has to start with a letter or underscore, but starts with ='); 69 } elseif (preg_match('/^[a-zA-Z_]{1}[a-zA-Z_0-9]*$/', $this->name) == false) { 70 throw new ReflectionException('Annotation parameter name may contain letters, underscores and numbers, but contains an invalid character.'); 69 71 } 70 72 … … 82 84 83 85 default: 84 if (strlen($this->name) == 0 && preg_match('/^[a-zA-Z_]$/', $token) == false) {85 throw new ReflectionException('Annotation parameter name has to start with a letter or underscore, but starts with ' . $token);86 } elseif (preg_match('/^[a-zA-Z_0-9]$/', $token) == false) {87 throw new ReflectionException('Annotation parameter name may contain letters, underscores and numbers, but contains ' . $token);88 }89 90 86 $this->name .= $token; 91 87 } trunk/src/test/php/net/stubbles/reflection/annotations/parser/state/stubAnnotationParamNameStateTestCase.php
r454 r455 60 60 * test processing the equal sign 61 61 */ 62 public function testProcessEqualSign ()62 public function testProcessEqualSignOnStart() 63 63 { 64 $this->mockAnnotationParser->expectOnce('registerAnnotationParam', array('a')); 64 $this->mockAnnotationParser->expectNever('registerAnnotationParam'); 65 $this->mockAnnotationParser->expectNever('changeState'); 66 $this->expectException('ReflectionException'); 67 $this->paramNameState->process('='); 68 } 69 70 /** 71 * test processing the equal sign 72 */ 73 public function testProcessEqualSignAfterCorrectParamName() 74 { 75 $this->mockAnnotationParser->expectOnce('registerAnnotationParam', array('abc_123')); 65 76 $this->mockAnnotationParser->expectOnce('changeState', array(stubAnnotationState::PARAM_VALUE)); 66 $this->paramNameState->process('a ');77 $this->paramNameState->process('abc_123'); 67 78 $this->paramNameState->process('='); 68 69 $this->paramNameState->selected(); 79 } 80 81 /** 82 * test processing the equal sign 83 */ 84 public function testProcessEqualSignAfterInCorrectParamName() 85 { 86 $this->mockAnnotationParser->expectNever('registerAnnotationParam'); 87 $this->mockAnnotationParser->expectNever('changeState'); 70 88 $this->expectException('ReflectionException'); 89 $this->paramNameState->process('1a'); 71 90 $this->paramNameState->process('='); 72 91 } … … 84 103 $this->paramNameState->process(')'); 85 104 } 86 87 /** 88 * test processing an illegal character on start of the annotation parameter name 89 */ 90 public function testProcessIllegalCharacterOnStart() 91 { 92 $this->expectException('ReflectionException'); 93 $this->paramNameState->process('1'); 94 } 95 105 96 106 /** 97 107 * test processing other characters … … 103 113 $this->paramNameState->process('_'); 104 114 $this->assertEqual($this->paramNameState->getName(), 'a1_'); 105 106 $this->expectException('ReflectionException');107 $this->paramNameState->process(']');108 115 } 109 116 }
