Changeset 1305
- Timestamp:
- 01/27/08 21:30:19 (10 months ago)
- Files:
-
- trunk/src/main/php/net/stubbles/rdbms/querybuilder/stubDatabaseSelect.php (modified) (1 diff)
- trunk/src/test/AllTests.php (modified) (2 diffs)
- trunk/src/test/php/net/stubbles/reflection/ReflectionTestSuite.php (modified) (1 diff)
- trunk/src/test/php/net/stubbles/reflection/annotations/parser/state/stubAnnotationAnnotationStateTestCase.php (modified) (8 diffs)
- trunk/src/test/php/net/stubbles/reflection/annotations/parser/state/stubAnnotationArgumentStateTestCase.php (modified) (5 diffs)
- trunk/src/test/php/net/stubbles/reflection/annotations/parser/state/stubAnnotationDocblockStateTestCase.php (modified) (5 diffs)
- trunk/src/test/php/net/stubbles/reflection/annotations/parser/state/stubAnnotationNameStateTestCase.php (modified) (13 diffs)
- trunk/src/test/php/net/stubbles/reflection/annotations/parser/state/stubAnnotationParamNameStateTestCase.php (modified) (5 diffs)
- trunk/src/test/php/net/stubbles/reflection/annotations/parser/state/stubAnnotationParamValueStateTestCase.php (modified) (5 diffs)
- trunk/src/test/php/net/stubbles/reflection/annotations/parser/state/stubAnnotationParamsStateTestCase.php (modified) (6 diffs)
- trunk/src/test/php/net/stubbles/reflection/annotations/parser/state/stubAnnotationTextStateTestCase.php (modified) (5 diffs)
- trunk/src/test/php/net/stubbles/reflection/annotations/parser/state/stubAnnotationTypeStateTestCase.php (modified) (5 diffs)
- trunk/src/test/php/net/stubbles/reflection/annotations/parser/stubAnnotationStateParserTestCase.php (modified) (4 diffs)
- trunk/src/test/php/net/stubbles/reflection/annotations/stubAnnotationFactoryApplicableTestCase.php (modified) (3 diffs)
- trunk/src/test/php/net/stubbles/reflection/annotations/stubAnnotationFactoryBuildTestCase.php (modified) (7 diffs)
- trunk/src/test/php/net/stubbles/reflection/annotations/stubAnnotationFactoryTestCase.php (modified) (10 diffs)
- trunk/src/test/php/net/stubbles/reflection/stubReflectionClassTestCase.php (modified) (7 diffs)
- trunk/src/test/php/net/stubbles/reflection/stubReflectionExtensionTestCase.php (modified) (4 diffs)
- trunk/src/test/php/net/stubbles/reflection/stubReflectionFunctionTestCase.php (modified) (3 diffs)
- trunk/src/test/php/net/stubbles/reflection/stubReflectionMethodTestCase.php (modified) (4 diffs)
- trunk/src/test/php/net/stubbles/reflection/stubReflectionObjectTestCase.php (modified) (7 diffs)
- trunk/src/test/php/net/stubbles/reflection/stubReflectionPackageTestCase.php (modified) (5 diffs)
- trunk/src/test/php/net/stubbles/reflection/stubReflectionParameterTestCase.php (modified) (5 diffs)
- trunk/src/test/php/net/stubbles/reflection/stubReflectionPrimitiveTestCase.php (modified) (8 diffs)
- trunk/src/test/php/net/stubbles/reflection/stubReflectionPropertyTestCase.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/main/php/net/stubbles/rdbms/querybuilder/stubDatabaseSelect.php
r1303 r1305 7 7 * @subpackage rdbms_querybuilder 8 8 */ 9 stubClassLoader::load('net::stubbles:: util::validators::stubAndCriterion',10 'net::stubbles:: util::validators::stubCriterion',9 stubClassLoader::load('net::stubbles::rdbms::criteria::stubAndCriterion', 10 'net::stubbles::rdbms::criteria::stubCriterion', 11 11 'net::stubbles::rdbms::querybuilder::stubDatabaseTableDescription', 12 12 'net::stubbles::rdbms::querybuilder::stubDatabaseTableJoin' trunk/src/test/AllTests.php
r1304 r1305 31 31 require_once $dir . '/php/net/stubbles/php/PHPTestSuite.php'; 32 32 require_once $dir . '/php/net/stubbles/rdbms/RDBMSTestSuite.php'; 33 require_once $dir . '/php/net/stubbles/reflection/ReflectionTestSuite.php'; 33 34 require_once $dir . '/php/net/stubbles/util/UtilTestSuite.php'; 34 35 require_once $dir . '/php/net/stubbles/service/ServiceTestSuite.php'; … … 67 68 $suite->addTestSuite('PHPTestSuite'); 68 69 $suite->addTestSuite('RDBMSTestSuite'); 70 $suite->addTestSuite('ReflectionTestSuite'); 69 71 $suite->addTestSuite('UtilTestSuite'); 70 72 $suite->addTestSuite('ServiceTestSuite'); trunk/src/test/php/net/stubbles/reflection/ReflectionTestSuite.php
r1072 r1305 13 13 * @subpackage test 14 14 */ 15 class ReflectionTestSuite extends TestSuite15 class ReflectionTestSuite extends PHPUnit_Framework_TestSuite 16 16 { 17 17 /** 18 * constructor 18 * returns the test suite to be run 19 * 20 * @return PHPUnit_Framework_TestSuite 19 21 */ 20 public function __construct()22 public static function suite() 21 23 { 22 $this->TestSuite('All Reflection tests'); 24 $suite = new self(); 25 $dir = dirname(__FILE__); 23 26 // annotations 24 $ this->addTestFile(dirname(__FILE__) . '/annotations/stubAnnotationFactoryTestCase.php');25 $ this->addTestFile(dirname(__FILE__) . '/annotations/stubAnnotationFactoryApplicableTestCase.php');26 $ this->addTestFile(dirname(__FILE__) . '/annotations/stubAnnotationFactoryBuildTestCase.php');27 $suite->addTestFile($dir . '/annotations/stubAnnotationFactoryApplicableTestCase.php'); 28 $suite->addTestFile($dir . '/annotations/stubAnnotationFactoryBuildTestCase.php'); 29 $suite->addTestFile($dir . '/annotations/stubAnnotationFactoryTestCase.php'); 27 30 28 31 // parser 29 $ this->addTestFile(dirname(__FILE__). '/annotations/parser/stubAnnotationStateParserTestCase.php');30 $ this->addTestFile(dirname(__FILE__). '/annotations/parser/state/stubAnnotationAnnotationStateTestCase.php');31 $ this->addTestFile(dirname(__FILE__). '/annotations/parser/state/stubAnnotationArgumentStateTestCase.php');32 $ this->addTestFile(dirname(__FILE__). '/annotations/parser/state/stubAnnotationDocblockStateTestCase.php');33 $ this->addTestFile(dirname(__FILE__). '/annotations/parser/state/stubAnnotationNameStateTestCase.php');34 $ this->addTestFile(dirname(__FILE__). '/annotations/parser/state/stubAnnotationParamNameStateTestCase.php');35 $ this->addTestFile(dirname(__FILE__). '/annotations/parser/state/stubAnnotationParamsStateTestCase.php');36 $ this->addTestFile(dirname(__FILE__). '/annotations/parser/state/stubAnnotationParamValueStateTestCase.php');37 $ this->addTestFile(dirname(__FILE__). '/annotations/parser/state/stubAnnotationTextStateTestCase.php');38 $ this->addTestFile(dirname(__FILE__). '/annotations/parser/state/stubAnnotationTypeStateTestCase.php');32 $suite->addTestFile($dir . '/annotations/parser/stubAnnotationStateParserTestCase.php'); 33 $suite->addTestFile($dir . '/annotations/parser/state/stubAnnotationAnnotationStateTestCase.php'); 34 $suite->addTestFile($dir . '/annotations/parser/state/stubAnnotationArgumentStateTestCase.php'); 35 $suite->addTestFile($dir . '/annotations/parser/state/stubAnnotationDocblockStateTestCase.php'); 36 $suite->addTestFile($dir . '/annotations/parser/state/stubAnnotationNameStateTestCase.php'); 37 $suite->addTestFile($dir . '/annotations/parser/state/stubAnnotationParamNameStateTestCase.php'); 38 $suite->addTestFile($dir . '/annotations/parser/state/stubAnnotationParamsStateTestCase.php'); 39 $suite->addTestFile($dir . '/annotations/parser/state/stubAnnotationParamValueStateTestCase.php'); 40 $suite->addTestFile($dir . '/annotations/parser/state/stubAnnotationTextStateTestCase.php'); 41 $suite->addTestFile($dir . '/annotations/parser/state/stubAnnotationTypeStateTestCase.php'); 39 42 40 43 // default reflection package 41 $this->addTestFile(dirname(__FILE__) . '/stubReflectionClassTestCase.php'); 42 $this->addTestFile(dirname(__FILE__) . '/stubReflectionExtensionTestCase.php'); 43 $this->addTestFile(dirname(__FILE__) . '/stubReflectionFunctionTestCase.php'); 44 $this->addTestFile(dirname(__FILE__) . '/stubReflectionMethodTestCase.php'); 45 $this->addTestFile(dirname(__FILE__) . '/stubReflectionObjectTestCase.php'); 46 $this->addTestFile(dirname(__FILE__) . '/stubReflectionPackageTestCase.php'); 47 $this->addTestFile(dirname(__FILE__) . '/stubReflectionParameterTestCase.php'); 48 $this->addTestFile(dirname(__FILE__) . '/stubReflectionPropertyTestCase.php'); 49 $this->addTestFile(dirname(__FILE__) . '/stubReflectionPrimitiveTestCase.php'); 44 $suite->addTestFile($dir . '/stubReflectionClassTestCase.php'); 45 $suite->addTestFile($dir . '/stubReflectionExtensionTestCase.php'); 46 $suite->addTestFile($dir . '/stubReflectionFunctionTestCase.php'); 47 $suite->addTestFile($dir . '/stubReflectionMethodTestCase.php'); 48 $suite->addTestFile($dir . '/stubReflectionObjectTestCase.php'); 49 $suite->addTestFile($dir . '/stubReflectionPackageTestCase.php'); 50 $suite->addTestFile($dir . '/stubReflectionParameterTestCase.php'); 51 $suite->addTestFile($dir . '/stubReflectionPropertyTestCase.php'); 52 $suite->addTestFile($dir . '/stubReflectionPrimitiveTestCase.php'); 53 return $suite; 50 54 } 51 55 } trunk/src/test/php/net/stubbles/reflection/annotations/parser/state/stubAnnotationAnnotationStateTestCase.php
r1227 r1305 8 8 */ 9 9 stubClassLoader::load('net::stubbles::reflection::annotations::parser::state::stubAnnotationAnnotationState'); 10 Mock::generate('stubAnnotationParser');11 10 /** 12 11 * Test for net::stubbles::reflection::annotations::parser::state::stubAnnotationAnnotationState. … … 15 14 * @subpackage reflection_annotations_parser_state_test 16 15 */ 17 class stubAnnotationAnnotationStateTestCase extends UnitTestCase16 class stubAnnotationAnnotationStateTestCase extends PHPUnit_Framework_TestCase 18 17 { 19 18 /** … … 35 34 public function setUp() 36 35 { 37 $this->mockAnnotationParser = new MockstubAnnotationParser();36 $this->mockAnnotationParser = $this->getMock('stubAnnotationParser'); 38 37 $this->annotationState = new stubAnnotationAnnotationState($this->mockAnnotationParser); 39 38 } … … 41 40 /** 42 41 * test processing a line break 42 * 43 * @test 43 44 */ 44 public function testProcessLinebreak()45 public function processLinebreak() 45 46 { 46 $this->mockAnnotationParser->expectOnce('changeState', array(stubAnnotationState::DOCBLOCK)); 47 $this->mockAnnotationParser->expects($this->once()) 48 ->method('changeState') 49 ->with($this->equalTo(stubAnnotationState::DOCBLOCK)); 47 50 $this->annotationState->process("\n"); 48 51 } … … 50 53 /** 51 54 * test processing an argument parenthesis 55 * 56 * @test 52 57 */ 53 public function testProcessArgumentParenthesis()58 public function processArgumentParenthesis() 54 59 { 55 $this->mockAnnotationParser->expectOnce('changeState', array(stubAnnotationState::ARGUMENT)); 60 $this->mockAnnotationParser->expects($this->once()) 61 ->method('changeState') 62 ->with($this->equalTo(stubAnnotationState::ARGUMENT)); 56 63 $this->annotationState->process('{'); 57 64 } … … 59 66 /** 60 67 * test processing a type parenthesis 68 * 69 * @test 61 70 */ 62 public function testProcessTypeParenthesis()71 public function processTypeParenthesis() 63 72 { 64 $this->mockAnnotationParser->expectOnce('changeState', array(stubAnnotationState::ANNOTATION_TYPE)); 73 $this->mockAnnotationParser->expects($this->once()) 74 ->method('changeState') 75 ->with($this->equalTo(stubAnnotationState::ANNOTATION_TYPE)); 65 76 $this->annotationState->process('['); 66 77 } … … 68 79 /** 69 80 * test processing a value parenthesis 81 * 82 * @test 70 83 */ 71 public function testProcessValueParenthesis()84 public function processValueParenthesis() 72 85 { 73 $this->mockAnnotationParser->expectOnce('changeState', array(stubAnnotationState::PARAMS)); 86 $this->mockAnnotationParser->expects($this->once()) 87 ->method('changeState') 88 ->with($this->equalTo(stubAnnotationState::PARAMS)); 74 89 $this->annotationState->process('('); 75 90 } … … 77 92 /** 78 93 * test processing a value parenthesis 94 * 95 * @test 79 96 */ 80 public function testProcessOtherCharacters()97 public function processOtherCharacters() 81 98 { 82 $this->mockAnnotationParser->expect Never('changeState');99 $this->mockAnnotationParser->expects($this->never())->method('changeState'); 83 100 $this->annotationState->process('a'); 84 101 $this->annotationState->process('1'); trunk/src/test/php/net/stubbles/reflection/annotations/parser/state/stubAnnotationArgumentStateTestCase.php
r1227 r1305 8 8 */ 9 9 stubClassLoader::load('net::stubbles::reflection::annotations::parser::state::stubAnnotationArgumentState'); 10 Mock::generate('stubAnnotationParser');11 10 /** 12 11 * Test for net::stubbles::reflection::annotations::parser::state::stubAnnotationArgumentState. … … 15 14 * @subpackage reflection_annotations_parser_state_test 16 15 */ 17 class stubAnnotationArgumentStateTestCase extends UnitTestCase16 class stubAnnotationArgumentStateTestCase extends PHPUnit_Framework_TestCase 18 17 { 19 18 /** … … 35 34 public function setUp() 36 35 { 37 $this->mockAnnotationParser = new MockstubAnnotationParser();36 $this->mockAnnotationParser = $this->getMock('stubAnnotationParser'); 38 37 $this->annotationArgumentState = new stubAnnotationArgumentState($this->mockAnnotationParser); 39 38 } … … 41 40 /** 42 41 * test processing a closing argument parenthesis 42 * 43 * @test 43 44 */ 44 public function testProcessArgumentParenthesis()45 public function processArgumentParenthesis() 45 46 { 46 $this->mockAnnotationParser->expectOnce('setAnnotationForArgument', array('a')); 47 $this->mockAnnotationParser->expect('changeState', array(stubAnnotationState::ANNOTATION)); 48 $this->mockAnnotationParser->expectCallcount('changeState', 2); 49 47 $this->mockAnnotationParser->expects($this->once()) 48 ->method('setAnnotationForArgument') 49 ->with($this->equalTo('a')); 50 $this->mockAnnotationParser->expects($this->exactly(2)) 51 ->method('changeState') 52 ->with($this->equalTo(stubAnnotationState::ANNOTATION)); 53 50 54 $this->annotationArgumentState->process('}'); 51 55 $this->annotationArgumentState->process('a'); … … 55 59 /** 56 60 * test processing other characters 61 * 62 * @test 57 63 */ 58 public function testProcessOtherCharacters()64 public function processOtherCharacters() 59 65 { 60 66 $this->annotationArgumentState->process('a'); 61 67 $this->annotationArgumentState->process('1'); 62 68 $this->annotationArgumentState->process('_'); 63 $this->assertEqual($this->annotationArgumentState->getArgument(), 'a1_'); 64 65 $this->expectException('ReflectionException'); 69 $this->assertEquals('a1_', $this->annotationArgumentState->getArgument()); 70 } 71 72 /** 73 * test processing other characters 74 * 75 * @test 76 * @expectedException ReflectionException 77 */ 78 public function processIllegalCharacters() 79 { 80 $this->annotationArgumentState->process('a'); 81 $this->annotationArgumentState->process('1'); 82 $this->annotationArgumentState->process('_'); 83 $this->assertEquals('a1_', $this->annotationArgumentState->getArgument()); 66 84 $this->annotationArgumentState->process(')'); 67 85 $this->annotationArgumentState->process('}'); trunk/src/test/php/net/stubbles/reflection/annotations/parser/state/stubAnnotationDocblockStateTestCase.php
r1227 r1305 8 8 */ 9 9 stubClassLoader::load('net::stubbles::reflection::annotations::parser::state::stubAnnotationDocblockState'); 10 Mock::generate('stubAnnotationParser');11 10 /** 12 11 * Test for net::stubbles::reflection::annotations::parser::state::stubAnnotationDocblockState. … … 15 14 * @subpackage reflection_annotations_parser_state_test 16 15 */ 17 class stubAnnotationDocblockStateTestCase extends UnitTestCase16 class stubAnnotationDocblockStateTestCase extends PHPUnit_Framework_TestCase 18 17 { 19 18 /** … … 29 28 */ 30 29 protected $mockAnnotationParser; 31 30 32 31 /** 33 32 * set up test environment … … 35 34 public function setUp() 36 35 { 37 $this->mockAnnotationParser = new MockstubAnnotationParser();36 $this->mockAnnotationParser = $this->getMock('stubAnnotationParser'); 38 37 $this->docblockState = new stubAnnotationDocblockState($this->mockAnnotationParser); 39 38 } 40 39 41 40 /** 42 41 * test processing a @ 42 * 43 * @test 43 44 */ 44 public function testProcessAtSign()45 public function processAtSign() 45 46 { 46 $this->mockAnnotationParser->expectOnce('changeState', array(stubAnnotationState::ANNOTATION_NAME)); 47 $this->mockAnnotationParser->expects($this->once()) 48 ->method('changeState') 49 ->with($this->equalTo(stubAnnotationState::ANNOTATION_NAME)); 47 50 $this->docblockState->process('@'); 48 51 } 49 52 50 53 /** 51 54 * test processing word characters 55 * 56 * @test 52 57 */ 53 public function testProcessStateChangingCharacterCharacter()58 public function processStateChangingCharacterCharacter() 54 59 { 55 $this->mockAnnotationParser->expect('changeState', array(stubAnnotationState::TEXT)); 56 $this->mockAnnotationParser->expectCallcount('changeState', 6); 60 $this->mockAnnotationParser->expects($this->exactly(6)) 61 ->method('changeState') 62 ->with($this->equalTo(stubAnnotationState::TEXT)); 57 63 $this->docblockState->process('a'); 58 64 $this->docblockState->process('1'); … … 62 68 $this->docblockState->process('.'); 63 69 } 64 70 65 71 /** 66 72 * test processing characters that should not change the state 73 * 74 * @test 67 75 */ 68 public function testProcessNoneStateChangingCharacters()76 public function processNoneStateChangingCharacters() 69 77 { 70 $this->mockAnnotationParser->expect Never('changeState');78 $this->mockAnnotationParser->expects($this->never())->method('changeState'); 71 79 $this->docblockState->process('*'); 72 80 $this->docblockState->process(' '); trunk/src/test/php/net/stubbles/reflection/annotations/parser/state/stubAnnotationNameStateTestCase.php
r1227 r1305 8 8 */ 9 9 stubClassLoader::load('net::stubbles::reflection::annotations::parser::state::stubAnnotationNameState'); 10 Mock::generate('stubAnnotationParser');11 10 /** 12 11 * Test for net::stubbles::reflection::annotations::parser::state::stubAnnotationNameState. … … 15 14 * @subpackage reflection_annotations_parser_state_test 16 15 */ 17 class stubAnnotationNameStateTestCase extends UnitTestCase16 class stubAnnotationNameStateTestCase extends PHPUnit_Framework_TestCase 18 17 { 19 18 /** … … 35 34 public function setUp() 36 35 { 37 $this->mockAnnotationParser = new MockstubAnnotationParser();36 $this->mockAnnotationParser = $this->getMock('stubAnnotationParser'); 38 37 $this->annotationNameState = new stubAnnotationNameState($this->mockAnnotationParser); 39 38 } … … 41 40 /** 42 41 * test processing a space element 43 */ 44 public function testProcessSpace() 45 { 46 $this->mockAnnotationParser->expectAt(0, 'changeState', array(stubAnnotationState::DOCBLOCK)); 47 $this->mockAnnotationParser->expectOnce('registerAnnotation', array('a')); 48 $this->mockAnnotationParser->expectAt(1, 'changeState', array(stubAnnotationState::ANNOTATION)); 42 * 43 * @test 44 */ 45 public function processSpaceAtStart() 46 { 47 $this->mockAnnotationParser->expects($this->once()) 48 ->method('changeState') 49 ->with($this->equalTo(stubAnnotationState::DOCBLOCK)); 50 $this->mockAnnotationParser->expects($this->never())->method('registerAnnotation'); 49 51 50 52 $this->annotationNameState->process(' '); 53 } 54 55 /** 56 * test processing a space element 57 * 58 * @test 59 */ 60 public function processSpace() 61 { 62 $this->mockAnnotationParser->expects($this->once()) 63 ->method('changeState') 64 ->with($this->equalTo(stubAnnotationState::ANNOTATION)); 65 $this->mockAnnotationParser->expects($this->once()) 66 ->method('registerAnnotation') 67 ->with($this->equalTo('a')); 68 51 69 $this->annotationNameState->process('a'); 52 70 $this->annotationNameState->process(' '); … … 55 73 /** 56 74 * test processing a line break 57 */ 58 public function testProcessLineBreak() 59 { 60 $this->mockAnnotationParser->expectOnce('registerAnnotation', array('a')); 61 $this->mockAnnotationParser->expectCallcount('changeState', 2, array(stubAnnotationState::DOCBLOCK)); 75 * 76 * @test 77 */ 78 public function processLineBreak() 79 { 80 $this->mockAnnotationParser->expects($this->once()) 81 ->method('registerAnnotation') 82 ->with($this->equalTo('a')); 83 $this->mockAnnotationParser->expects($this->exactly(2)) 84 ->method('changeState') 85 ->with($this->equalTo(stubAnnotationState::DOCBLOCK)); 62 86 63 87 $this->annotationNameState->process("\n"); … … 68 92 /** 69 93 * test processing an argument parenthesis 70 */ 71 public function testProcessArgumentParenthesis() 72 { 73 $this->mockAnnotationParser->expectOnce('registerAnnotation', array('a')); 74 $this->mockAnnotationParser->expectOnce('changeState', array(stubAnnotationState::ARGUMENT)); 94 * 95 * @test 96 */ 97 public function processArgumentParenthesis() 98 { 99 $this->mockAnnotationParser->expects($this->once()) 100 ->method('registerAnnotation') 101 ->with($this->equalTo('a')); 102 $this->mockAnnotationParser->expects($this->once()) 103 ->method('changeState') 104 ->with($this->equalTo(stubAnnotationState::ARGUMENT)); 75 105 76 106 $this->annotationNameState->process('a'); 77 107 $this->annotationNameState->process('{'); 78 108 } 109 110 /** 111 * test processing an argument parenthesis 112 * 113 * @test 114 * @expectedException ReflectionException 115 */ 116 public function processArgumentParenthesisAfterSelected() 117 { 118 $this->annotationNameState->process('a'); 79 119 $this->annotationNameState->selected(); 80 $this->expectException('ReflectionException');81 120 $this->annotationNameState->process('{'); 82 121 } … … 84 123 /** 85 124 * test processing a type parenthesis 86 */ 87 public function testProcessTypeParenthesis() 88 { 89 $this->mockAnnotationParser->expectOnce('registerAnnotation', array('a')); 90 $this->mockAnnotationParser->expectOnce('changeState', array(stubAnnotationState::ANNOTATION_TYPE)); 125 * 126 * @test 127 */ 128 public function processTypeParenthesis() 129 { 130 $this->mockAnnotationParser->expects($this->once()) 131 ->method('registerAnnotation') 132 ->with($this->equalTo('a')); 133 $this->mockAnnotationParser->expects($this->once()) 134 ->method('changeState') 135 ->with($this->equalTo(stubAnnotationState::ANNOTATION_TYPE)); 91 136 92 137 $this->annotationNameState->process('a'); 93 138 $this->annotationNameState->process('['); 94 139 } 140 141 /** 142 * test processing a type parenthesis 143 * 144 * @test 145 * @expectedException ReflectionException 146 */ 147 public function processTypeParenthesisAfterSelected() 148 { 149 $this->annotationNameState->process('a'); 95 150 $this->annotationNameState->selected(); 96 $this->expectException('ReflectionException');97 151 $this->annotationNameState->process('['); 98 152 } … … 100 154 /** 101 155 * test processing a value parenthesis 102 */ 103 public function testProcessValueParenthesis() 104 { 105 $this->mockAnnotationParser->expectOnce('registerAnnotation', array('a')); 106 $this->mockAnnotationParser->expectOnce('changeState', array(stubAnnotationState::PARAMS)); 156 * 157 * @test 158 */ 159 public function processValueParenthesis() 160 { 161 $this->mockAnnotationParser->expects($this->once()) 162 ->method('registerAnnotation') 163 ->with($this->equalTo('a')); 164 $this->mockAnnotationParser->expects($this->once()) 165 ->method('changeState') 166 ->with($this->equalTo(stubAnnotationState::PARAMS)); 107 167 108 168 $this->annotationNameState->process('a'); 109 169 $this->annotationNameState->process('('); 110 170 } 171 172 /** 173 * test processing a value parenthesis 174 * 175 * @test 176 * @expectedException ReflectionException 177 */ 178 public function processValueParenthesisFailsAfterSelected() 179 { 180 $this->annotationNameState->process('a'); 111 181 $this->annotationNameState->selected(); 112 $this->expectException('ReflectionException');113 182 $this->annotationNameState->process('('); 114 183 } … … 116 185 /** 117 186 * test processing other characters 118 */ 119 public function testProcessOtherCharacters() 120 { 121 $this->annotationNameState->process('a'); 122 $this->annotationNameState->process('1'); 123 $this->annotationNameState->process('_'); 124 $this->assertEqual($this->annotationNameState->getName(), 'a1_'); 125 } 126 127 /** 128 * test processing illegal characters 129 */ 130 public function testProcessIllegalCharactersFollowedBySpace() 131 { 132 $this->annotationNameState->process('a'); 133 $this->annotationNameState->process('1'); 134 $this->annotationNameState->process('_'); 135 $this->expectException('ReflectionException'); 187 * 188 * @test 189 */ 190 public function processOtherCharacters() 191 { 192 $this->annotationNameState->process('a'); 193 $this->annotationNameState->process('1'); 194 $this->annotationNameState->process('_'); 195 $this->assertEquals('a1_', $this->annotationNameState->getName()); 196 } 197 198 /** 199 * test processing illegal characters 200 * 201 * @test 202 * @expectedException ReflectionException 203 */ 204 public function processIllegalCharactersFollowedBySpace() 205 { 206 $this->annotationNameState->process('a'); 207 $this->annotationNameState->process('1'); 208 $this->annotationNameState->process('_'); 136 209 $this->annotationNameState->process(')'); 137 210 $this->annotationNameState->process(' '); … … 140 213 /** 141 214 * test processing illegal characters 142 */ 143 public function testProcessIllegalCharactersFollowedByLineBreak() 144 { 145 $this->annotationNameState->process('a'); 146 $this->annotationNameState->process('1'); 147 $this->annotationNameState->process('_'); 148 $this->expectException('ReflectionException'); 215 * 216 * @test 217 * @expectedException ReflectionException 218 */ 219 public function processIllegalCharactersFollowedByLineBreak() 220 { 221 $this->annotationNameState->process('a'); 222 $this->annotationNameState->process('1'); 223 $this->annotationNameState->process('_'); 149 224 $this->annotationNameState->process(')'); 150 225 $this->annotationNameState->process("\n"); … … 153 228 /** 154 229 * test processing illegal characters 155 */ 156 public function testProcessIllegalCharactersFollowedByArgumentParenthesis() 157 { 158 $this->annotationNameState->process('a'); 159 $this->annotationNameState->process('1'); 160 $this->annotationNameState->process('_'); 161 $this->expectException('ReflectionException'); 230 * 231 * @test 232 * @expectedException ReflectionException 233 */ 234 public function processIllegalCharactersFollowedByArgumentParenthesis() 235 { 236 $this->annotationNameState->process('a'); 237 $this->annotationNameState->process('1'); 238 $this->annotationNameState->process('_'); 162 239 $this->annotationNameState->process(')'); 163 240 $this->annotationNameState->process('{'); … … 166 243 /** 167 244 * test processing illegal characters 168 */ 169 public function testProcessIllegalCharactersFollowedByTypeParenthesis() 170 { 171 $this->annotationNameState->process('a'); 172 $this->annotationNameState->process('1'); 173 $this->annotationNameState->process('_'); 174 $this->expectException('ReflectionException'); 245 * 246 * @test 247 * @expectedException ReflectionException 248 */ 249 public function processIllegalCharactersFollowedByTypeParenthesis() 250 { 251 $this->annotationNameState->process('a'); 252 $this->annotationNameState->process('1'); 253 $this->annotationNameState->process('_'); 175 254 $this->annotationNameState->process(')'); 176 255 $this->annotationNameState->process('['); … … 179 258 /** 180 259 * test processing illegal characters 181 */ 182 public function testProcessIllegalCharactersFollowedByValueParenthesis() 183 { 184 $this->annotationNameState->process('a'); 185 $this->annotationNameState->process('1'); 186 $this->annotationNameState->process('_'); 187 $this->expectException('ReflectionException'); 260 * 261 * @test 262 * @expectedException ReflectionException 263 */ 264 public function processIllegalCharactersFollowedByValueParenthesis() 265 { 266 $this->annotationNameState->process('a'); 267 $this->annotationNameState->process('1'); 268 $this->annotationNameState->process('_'); 188 269 $this->annotationNameState->process(')'); 189 270 $this->annotationNameState->process('('); trunk/src/test/php/net/stubbles/reflection/annotations/parser/state/stubAnnotationParamNameStateTestCase.php
r1227 r1305 8 8 */ 9 9 stubClassLoader::load('net::stubbles::reflection::annotations::parser::state::stubAnnotationParamNameState'); 10 Mock::generate('stubAnnotationParser');11 10 /** 12 11 * Test for net::stubbles::reflection::annotations::parser::state::stubAnnotationParamNameState. … … 15 14 * @subpackage reflection_annotations_parser_state_test 16 15 */ 17 class stubAnnotationParamNameStateTestCase extends UnitTestCase16 class stubAnnotationParamNameStateTestCase extends PHPUnit_Framework_TestCase 18 17 { 19 18 /** … … 29 28 */ 30 29 protected $mockAnnotationParser; 31 30 32 31 /** 33 32 * set up test environment … … 35 34 public function setUp() 36 35 { 37 $this->mockAnnotationParser = new MockstubAnnotationParser();36 $this->mockAnnotationParser = $this->getMock('stubAnnotationParser'); 38 37 $this->paramNameState = new stubAnnotationParamNameState($this->mockAnnotationParser); 39 38 } 40 39 41 40 /** 42 41 * test processing quotation marks 42 * 43 * @test 43 44 */ 44 public function testProcessQuotationMarks()45 public function processSimpleQuotationMarks() 45 46 { 46 $this->mockAnnotationParser->expect('registerAnnotationParam', array('value')); 47 $this->mockAnnotationParser->expectAt(0, 'changeState', array(stubAnnotationState::PARAM_VALUE, '"')); 48 $this->mockAnnotationParser->expectAt(1, 'changeState', array(stubAnnotationState::PARAM_VALUE, "'")); 49 $this->mockAnnotationParser->expectCallcount('registerAnnotationParam', 2); 50 $this->mockAnnotationParser->expectCallcount('changeState', 2); 47 $this->mockAnnotationParser->expects($this->once()) 48 ->method('registerAnnotationParam') 49 ->with($this->equalTo('value')); 50 $this->mockAnnotationParser->expects($this->once()) 51 ->method('changeState') 52 ->with($this->equalTo(stubAnnotationState::PARAM_VALUE), $this->equalTo("'")); 53 54 $this->paramNameState->process("'"); 55 } 56 57 /** 58 * test processing quotation marks 59 * 60 * @test 61 */ 62 public function processQuotationMarks() 63 { 64 $this->mockAnnotationParser->expects($this->once()) 65 ->method('registerAnnotationParam') 66 ->with($this->equalTo('value')); 67 $this->mockAnnotationParser->expects($this->once()) 68 ->method('changeState') 69 ->with($this->equalTo(stubAnnotationState::PARAM_VALUE), $this->equalTo('"')); 70 51 71 $this->paramNameState->process('"'); 52 $this->paramNameState->process("'"); 53 54 $this->expectException('ReflectionException'); 72 } 73 74 /** 75 * test processing quotation marks 76 * 77 * @test 78 * @expectedException ReflectionException 79 */ 80 public function processQuotationMarksInvalidOffset() 81 { 82 $this->mockAnnotationParser->expects($this->never())->method('registerAnnotationParam'); 83 $this->mockAnnotationParser->expects($this->never())->method('changeState'); 55 84 $this->paramNameState->process('a'); 56 85 $this->paramNameState->process("'"); 57 86 } 58 87 88 /** 89 * test processing quotation marks 90 * 91 * @test 92 * @expectedException ReflectionException 93 */ 94 public function processQuotationMarksOnInvalidOffset() 95 { 96 $this->mockAnnotationParser->expects($this->never())->method('registerAnnotationParam'); 97 $this->mockAnnotationParser->expects($this->never())->method('changeState'); 98 $this->paramNameState->process('a'); 99 $this->paramNameState->process("'"); 100 } 101 59 102 /** 60 103 * test processing the equal sign 104 * 105 * @test 106 * @expectedException ReflectionException 61 107 */ 62 public function testProcessEqualSignOnStart()108 public function processEqualSignOnStart() 63 109 { 64 $this->mockAnnotationParser->expectNever('registerAnnotationParam'); 65 $this->mockAnnotationParser->expectNever('changeState'); 66 $this->expectException('ReflectionException'); 110 $this->mockAnnotationParser->expects($this->never())->method('registerAnnotationParam'); 111 $this->mockAnnotationParser->expects($this->never())->method('changeState'); 67 112 $this->paramNameState->process('='); 68 113 } 69 114 70 115 /** 71 116 * test processing the equal sign 117 * 118 * @test 72 119 */ 73 public function testProcessEqualSignAfterCorrectParamName()120 public function processEqualSignAfterCorrectParamName() 74 121 { 75 $this->mockAnnotationParser->expectOnce('registerAnnotationParam', array('abc_123')); 76 $this->mockAnnotationParser->expectOnce('changeState', array(stubAnnotationState::PARAM_VALUE)); 122 $this->mockAnnotationParser->expects($this->once()) 123 ->method('registerAnnotationParam') 124 ->with($this->equalTo('abc_123')); 125 $this->mockAnnotationParser->expects($this->once()) 126 ->method('changeState') 127 ->with($this->equalTo(stubAnnotationState::PARAM_VALUE)); 77 128 $this->paramNameState->process('abc_123'); 78 129 $this->paramNameState->process('='); 79 130 } 80 131 81 132 /** 82 133 * test processing the equal sign 134 &
