Changeset 1305

Show
Ignore:
Timestamp:
01/27/08 21:30:19 (10 months ago)
Author:
mikey
Message:

continued refactoring #118: converted tests for net::stubbles::reflection

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/main/php/net/stubbles/rdbms/querybuilder/stubDatabaseSelect.php

    r1303 r1305  
    77 * @subpackage  rdbms_querybuilder 
    88 */ 
    9 stubClassLoader::load('net::stubbles::util::validators::stubAndCriterion', 
    10                       'net::stubbles::util::validators::stubCriterion', 
     9stubClassLoader::load('net::stubbles::rdbms::criteria::stubAndCriterion', 
     10                      'net::stubbles::rdbms::criteria::stubCriterion', 
    1111                      'net::stubbles::rdbms::querybuilder::stubDatabaseTableDescription', 
    1212                      'net::stubbles::rdbms::querybuilder::stubDatabaseTableJoin' 
  • trunk/src/test/AllTests.php

    r1304 r1305  
    3131require_once $dir . '/php/net/stubbles/php/PHPTestSuite.php'; 
    3232require_once $dir . '/php/net/stubbles/rdbms/RDBMSTestSuite.php'; 
     33require_once $dir . '/php/net/stubbles/reflection/ReflectionTestSuite.php'; 
    3334require_once $dir . '/php/net/stubbles/util/UtilTestSuite.php'; 
    3435require_once $dir . '/php/net/stubbles/service/ServiceTestSuite.php'; 
     
    6768        $suite->addTestSuite('PHPTestSuite'); 
    6869        $suite->addTestSuite('RDBMSTestSuite'); 
     70        $suite->addTestSuite('ReflectionTestSuite'); 
    6971        $suite->addTestSuite('UtilTestSuite'); 
    7072        $suite->addTestSuite('ServiceTestSuite'); 
  • trunk/src/test/php/net/stubbles/reflection/ReflectionTestSuite.php

    r1072 r1305  
    1313 * @subpackage  test 
    1414 */ 
    15 class ReflectionTestSuite extends TestSuite 
     15class ReflectionTestSuite extends PHPUnit_Framework_TestSuite 
    1616{ 
    1717    /** 
    18      * constructor 
     18     * returns the test suite to be run 
     19     * 
     20     * @return  PHPUnit_Framework_TestSuite 
    1921     */ 
    20     public function __construct() 
     22    public static function suite() 
    2123    { 
    22         $this->TestSuite('All Reflection tests'); 
     24        $suite = new self(); 
     25        $dir   = dirname(__FILE__); 
    2326        // 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'); 
    2730         
    2831        // 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'); 
    3942         
    4043        // 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; 
    5054    } 
    5155} 
  • trunk/src/test/php/net/stubbles/reflection/annotations/parser/state/stubAnnotationAnnotationStateTestCase.php

    r1227 r1305  
    88 */ 
    99stubClassLoader::load('net::stubbles::reflection::annotations::parser::state::stubAnnotationAnnotationState'); 
    10 Mock::generate('stubAnnotationParser'); 
    1110/** 
    1211 * Test for net::stubbles::reflection::annotations::parser::state::stubAnnotationAnnotationState. 
     
    1514 * @subpackage  reflection_annotations_parser_state_test 
    1615 */ 
    17 class stubAnnotationAnnotationStateTestCase extends UnitTestCase 
     16class stubAnnotationAnnotationStateTestCase extends PHPUnit_Framework_TestCase 
    1817{ 
    1918    /** 
     
    3534    public function setUp() 
    3635    { 
    37         $this->mockAnnotationParser = new MockstubAnnotationParser(); 
     36        $this->mockAnnotationParser = $this->getMock('stubAnnotationParser'); 
    3837        $this->annotationState      = new stubAnnotationAnnotationState($this->mockAnnotationParser); 
    3938    } 
     
    4140    /** 
    4241     * test processing a line break 
     42     * 
     43     * @test 
    4344     */ 
    44     public function testProcessLinebreak() 
     45    public function processLinebreak() 
    4546    { 
    46         $this->mockAnnotationParser->expectOnce('changeState', array(stubAnnotationState::DOCBLOCK)); 
     47        $this->mockAnnotationParser->expects($this->once()) 
     48                                   ->method('changeState') 
     49                                   ->with($this->equalTo(stubAnnotationState::DOCBLOCK)); 
    4750        $this->annotationState->process("\n"); 
    4851    } 
     
    5053    /** 
    5154     * test processing an argument parenthesis 
     55     * 
     56     * @test 
    5257     */ 
    53     public function testProcessArgumentParenthesis() 
     58    public function processArgumentParenthesis() 
    5459    { 
    55         $this->mockAnnotationParser->expectOnce('changeState', array(stubAnnotationState::ARGUMENT)); 
     60        $this->mockAnnotationParser->expects($this->once()) 
     61                                   ->method('changeState') 
     62                                   ->with($this->equalTo(stubAnnotationState::ARGUMENT)); 
    5663        $this->annotationState->process('{'); 
    5764    } 
     
    5966    /** 
    6067     * test processing a type parenthesis 
     68     * 
     69     * @test 
    6170     */ 
    62     public function testProcessTypeParenthesis() 
     71    public function processTypeParenthesis() 
    6372    { 
    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)); 
    6576        $this->annotationState->process('['); 
    6677    } 
     
    6879    /** 
    6980     * test processing a value parenthesis 
     81     * 
     82     * @test 
    7083     */ 
    71     public function testProcessValueParenthesis() 
     84    public function processValueParenthesis() 
    7285    { 
    73         $this->mockAnnotationParser->expectOnce('changeState', array(stubAnnotationState::PARAMS)); 
     86        $this->mockAnnotationParser->expects($this->once()) 
     87                                   ->method('changeState') 
     88                                   ->with($this->equalTo(stubAnnotationState::PARAMS)); 
    7489        $this->annotationState->process('('); 
    7590    } 
     
    7792    /** 
    7893     * test processing a value parenthesis 
     94     * 
     95     * @test 
    7996     */ 
    80     public function testProcessOtherCharacters() 
     97    public function processOtherCharacters() 
    8198    { 
    82         $this->mockAnnotationParser->expectNever('changeState'); 
     99        $this->mockAnnotationParser->expects($this->never())->method('changeState'); 
    83100        $this->annotationState->process('a'); 
    84101        $this->annotationState->process('1'); 
  • trunk/src/test/php/net/stubbles/reflection/annotations/parser/state/stubAnnotationArgumentStateTestCase.php

    r1227 r1305  
    88 */ 
    99stubClassLoader::load('net::stubbles::reflection::annotations::parser::state::stubAnnotationArgumentState'); 
    10 Mock::generate('stubAnnotationParser'); 
    1110/** 
    1211 * Test for net::stubbles::reflection::annotations::parser::state::stubAnnotationArgumentState. 
     
    1514 * @subpackage  reflection_annotations_parser_state_test 
    1615 */ 
    17 class stubAnnotationArgumentStateTestCase extends UnitTestCase 
     16class stubAnnotationArgumentStateTestCase extends PHPUnit_Framework_TestCase 
    1817{ 
    1918    /** 
     
    3534    public function setUp() 
    3635    { 
    37         $this->mockAnnotationParser    = new MockstubAnnotationParser(); 
     36        $this->mockAnnotationParser    = $this->getMock('stubAnnotationParser'); 
    3837        $this->annotationArgumentState = new stubAnnotationArgumentState($this->mockAnnotationParser); 
    3938    } 
     
    4140    /** 
    4241     * test processing a closing argument parenthesis 
     42     * 
     43     * @test 
    4344     */ 
    44     public function testProcessArgumentParenthesis() 
     45    public function processArgumentParenthesis() 
    4546    { 
    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                                    
    5054        $this->annotationArgumentState->process('}'); 
    5155        $this->annotationArgumentState->process('a'); 
     
    5559    /** 
    5660     * test processing other characters 
     61     * 
     62     * @test 
    5763     */ 
    58     public function testProcessOtherCharacters() 
     64    public function processOtherCharacters() 
    5965    { 
    6066        $this->annotationArgumentState->process('a'); 
    6167        $this->annotationArgumentState->process('1'); 
    6268        $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()); 
    6684        $this->annotationArgumentState->process(')'); 
    6785        $this->annotationArgumentState->process('}'); 
  • trunk/src/test/php/net/stubbles/reflection/annotations/parser/state/stubAnnotationDocblockStateTestCase.php

    r1227 r1305  
    88 */ 
    99stubClassLoader::load('net::stubbles::reflection::annotations::parser::state::stubAnnotationDocblockState'); 
    10 Mock::generate('stubAnnotationParser'); 
    1110/** 
    1211 * Test for net::stubbles::reflection::annotations::parser::state::stubAnnotationDocblockState. 
     
    1514 * @subpackage  reflection_annotations_parser_state_test 
    1615 */ 
    17 class stubAnnotationDocblockStateTestCase extends UnitTestCase 
     16class stubAnnotationDocblockStateTestCase extends PHPUnit_Framework_TestCase 
    1817{ 
    1918    /** 
     
    2928     */ 
    3029    protected $mockAnnotationParser; 
    31      
     30 
    3231    /** 
    3332     * set up test environment 
     
    3534    public function setUp() 
    3635    { 
    37         $this->mockAnnotationParser = new MockstubAnnotationParser(); 
     36        $this->mockAnnotationParser = $this->getMock('stubAnnotationParser'); 
    3837        $this->docblockState        = new stubAnnotationDocblockState($this->mockAnnotationParser); 
    3938    } 
    40      
     39 
    4140    /** 
    4241     * test processing a @ 
     42     * 
     43     * @test 
    4344     */ 
    44     public function testProcessAtSign() 
     45    public function processAtSign() 
    4546    { 
    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)); 
    4750        $this->docblockState->process('@'); 
    4851    } 
    49      
     52 
    5053    /** 
    5154     * test processing word characters 
     55     * 
     56     * @test 
    5257     */ 
    53     public function testProcessStateChangingCharacterCharacter() 
     58    public function processStateChangingCharacterCharacter() 
    5459    { 
    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)); 
    5763        $this->docblockState->process('a'); 
    5864        $this->docblockState->process('1'); 
     
    6268        $this->docblockState->process('.'); 
    6369    } 
    64      
     70 
    6571    /** 
    6672     * test processing characters that should not change the state 
     73     * 
     74     * @test 
    6775     */ 
    68     public function testProcessNoneStateChangingCharacters() 
     76    public function processNoneStateChangingCharacters() 
    6977    { 
    70         $this->mockAnnotationParser->expectNever('changeState'); 
     78        $this->mockAnnotationParser->expects($this->never())->method('changeState'); 
    7179        $this->docblockState->process('*'); 
    7280        $this->docblockState->process(' '); 
  • trunk/src/test/php/net/stubbles/reflection/annotations/parser/state/stubAnnotationNameStateTestCase.php

    r1227 r1305  
    88 */ 
    99stubClassLoader::load('net::stubbles::reflection::annotations::parser::state::stubAnnotationNameState'); 
    10 Mock::generate('stubAnnotationParser'); 
    1110/** 
    1211 * Test for net::stubbles::reflection::annotations::parser::state::stubAnnotationNameState. 
     
    1514 * @subpackage  reflection_annotations_parser_state_test 
    1615 */ 
    17 class stubAnnotationNameStateTestCase extends UnitTestCase 
     16class stubAnnotationNameStateTestCase extends PHPUnit_Framework_TestCase 
    1817{ 
    1918    /** 
     
    3534    public function setUp() 
    3635    { 
    37         $this->mockAnnotationParser = new MockstubAnnotationParser(); 
     36        $this->mockAnnotationParser = $this->getMock('stubAnnotationParser'); 
    3837        $this->annotationNameState  = new stubAnnotationNameState($this->mockAnnotationParser); 
    3938    } 
     
    4140    /** 
    4241     * 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'); 
    4951         
    5052        $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         
    5169        $this->annotationNameState->process('a'); 
    5270        $this->annotationNameState->process(' '); 
     
    5573    /** 
    5674     * 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)); 
    6286         
    6387        $this->annotationNameState->process("\n"); 
     
    6892    /** 
    6993     * 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)); 
    75105         
    76106        $this->annotationNameState->process('a'); 
    77107        $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'); 
    79119        $this->annotationNameState->selected(); 
    80         $this->expectException('ReflectionException'); 
    81120        $this->annotationNameState->process('{'); 
    82121    } 
     
    84123    /** 
    85124     * 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)); 
    91136         
    92137        $this->annotationNameState->process('a'); 
    93138        $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'); 
    95150        $this->annotationNameState->selected(); 
    96         $this->expectException('ReflectionException'); 
    97151        $this->annotationNameState->process('['); 
    98152    } 
     
    100154    /** 
    101155     * 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)); 
    107167         
    108168        $this->annotationNameState->process('a'); 
    109169        $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'); 
    111181        $this->annotationNameState->selected(); 
    112         $this->expectException('ReflectionException'); 
    113182        $this->annotationNameState->process('('); 
    114183    } 
     
    116185    /** 
    117186     * 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('_'); 
    136209        $this->annotationNameState->process(')'); 
    137210        $this->annotationNameState->process(' '); 
     
    140213    /** 
    141214     * 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('_'); 
    149224        $this->annotationNameState->process(')'); 
    150225        $this->annotationNameState->process("\n"); 
     
    153228    /** 
    154229     * 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('_'); 
    162239        $this->annotationNameState->process(')'); 
    163240        $this->annotationNameState->process('{'); 
     
    166243    /** 
    167244     * 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('_'); 
    175254        $this->annotationNameState->process(')'); 
    176255        $this->annotationNameState->process('['); 
     
    179258    /** 
    180259     * 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('_'); 
    188269        $this->annotationNameState->process(')'); 
    189270        $this->annotationNameState->process('('); 
  • trunk/src/test/php/net/stubbles/reflection/annotations/parser/state/stubAnnotationParamNameStateTestCase.php

    r1227 r1305  
    88 */ 
    99stubClassLoader::load('net::stubbles::reflection::annotations::parser::state::stubAnnotationParamNameState'); 
    10 Mock::generate('stubAnnotationParser'); 
    1110/** 
    1211 * Test for net::stubbles::reflection::annotations::parser::state::stubAnnotationParamNameState. 
     
    1514 * @subpackage  reflection_annotations_parser_state_test 
    1615 */ 
    17 class stubAnnotationParamNameStateTestCase extends UnitTestCase 
     16class stubAnnotationParamNameStateTestCase extends PHPUnit_Framework_TestCase 
    1817{ 
    1918    /** 
     
    2928     */ 
    3029    protected $mockAnnotationParser; 
    31      
     30 
    3231    /** 
    3332     * set up test environment 
     
    3534    public function setUp() 
    3635    { 
    37         $this->mockAnnotationParser = new MockstubAnnotationParser(); 
     36        $this->mockAnnotationParser = $this->getMock('stubAnnotationParser'); 
    3837        $this->paramNameState       = new stubAnnotationParamNameState($this->mockAnnotationParser); 
    3938    } 
    40      
     39 
    4140    /** 
    4241     * test processing quotation marks 
     42     * 
     43     * @test 
    4344     */ 
    44     public function testProcessQuotationMarks() 
     45    public function processSimpleQuotationMarks() 
    4546    { 
    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         
    5171        $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'); 
    5584        $this->paramNameState->process('a'); 
    5685        $this->paramNameState->process("'"); 
    5786    } 
    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 
    59102    /** 
    60103     * test processing the equal sign 
     104     * 
     105     * @test 
     106     * @expectedException  ReflectionException 
    61107     */ 
    62     public function testProcessEqualSignOnStart() 
     108    public function processEqualSignOnStart() 
    63109    { 
    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'); 
    67112        $this->paramNameState->process('='); 
    68113    } 
    69      
     114 
    70115    /** 
    71116     * test processing the equal sign 
     117     * 
     118     * @test 
    72119     */ 
    73     public function testProcessEqualSignAfterCorrectParamName() 
     120    public function processEqualSignAfterCorrectParamName() 
    74121    { 
    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)); 
    77128        $this->paramNameState->process('abc_123'); 
    78129        $this->paramNameState->process('='); 
    79130    } 
    80      
     131 
    81132    /** 
    82133     * test processing the equal sign 
     134    &