Changeset 1282

Show
Ignore:
Timestamp:
01/22/08 18:40:54 (8 months ago)
Author:
mikey
Message:

continued refactoring #118: transformed tests for net::stubbles::websites::ipo::request::broker

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/main/php/net/stubbles/ipo/request/broker/annotations/stubStringFilterAnnotation.php

    r1223 r1282  
    6161    public function finish() 
    6262    { 
    63         if (null === $this->regex) { 
     63        if (null == $this->regex) { 
    6464            throw new ReflectionException('Can not use ' . $this->getClassName() . ' without setting the regular expression via regex property.'); 
    6565        } 
  • trunk/src/test/php/net/stubbles/ipo/IPOTestSuite.php

    r1274 r1282  
    3131        $suite->addTestFile($dir . '/request/stubRequestValueErrorTestCase.php'); 
    3232 
    33         #$suite->addTestFile($dir . '/request/broker/stubRequestBrokerTestCase.php'); 
    34         #$suite->addTestFile($dir . '/request/broker/annotations/stubAbstractFilterAnnotationTestCase.php'); 
    35         #$suite->addTestFile($dir . '/request/broker/annotations/stubFloatFilterAnnotationTestCase.php'); 
    36         #$suite->addTestFile($dir . '/request/broker/annotations/stubHTTPURLFilterAnnotationTestCase.php'); 
    37         #$suite->addTestFile($dir . '/request/broker/annotations/stubIntegerFilterAnnotationTestCase.php'); 
    38         #$suite->addTestFile($dir . '/request/broker/annotations/stubMailFilterAnnotationTestCase.php'); 
    39         #$suite->addTestFile($dir . '/request/broker/annotations/stubPasswordFilterAnnotationTestCase.php'); 
    40         #$suite->addTestFile($dir . '/request/broker/annotations/stubStringFilterAnnotationTestCase.php'); 
    41         #$suite->addTestFile($dir . '/request/broker/annotations/stubTextFilterAnnotationTestCase.php'); 
     33        $suite->addTestFile($dir . '/request/broker/stubRequestBrokerTestCase.php'); 
     34        $suite->addTestFile($dir . '/request/broker/annotations/stubAbstractFilterAnnotationTestCase.php'); 
     35        $suite->addTestFile($dir . '/request/broker/annotations/stubFloatFilterAnnotationTestCase.php'); 
     36        $suite->addTestFile($dir . '/request/broker/annotations/stubHTTPURLFilterAnnotationTestCase.php'); 
     37        $suite->addTestFile($dir . '/request/broker/annotations/stubIntegerFilterAnnotationTestCase.php'); 
     38        $suite->addTestFile($dir . '/request/broker/annotations/stubMailFilterAnnotationTestCase.php'); 
     39        $suite->addTestFile($dir . '/request/broker/annotations/stubPasswordFilterAnnotationTestCase.php'); 
     40        $suite->addTestFile($dir . '/request/broker/annotations/stubStringFilterAnnotationTestCase.php'); 
     41        $suite->addTestFile($dir . '/request/broker/annotations/stubTextFilterAnnotationTestCase.php'); 
    4242 
    4343        $suite->addTestFile($dir . '/request/filters/stubFloatFilterTestCase.php'); 
  • trunk/src/test/php/net/stubbles/ipo/request/broker/annotations/stubAbstractFilterAnnotationTestCase.php

    r1223 r1282  
    1111                      'net::stubbles::ipo::request::stubRequestValueErrorFactory' 
    1212); 
    13 Mock::generatePartial('stubAbstractFilterAnnotation', 'PartialMockstubAbstractFilterAnnotation', array('doGetFilter')); 
    14 Mock::generate('stubFilter'); 
    15 Mock::generate('stubRequestValueErrorFactory'); 
     13/** 
     14 * Helper class to circumvent the filter generation for rve tests. 
     15 * 
     16 * @package     stubbles 
     17 * @subpackage  ipo_request_broker_annotations_test 
     18 */ 
    1619class TeststubAbstractFilterAnnotation extends stubAbstractFilterAnnotation 
    1720{ 
     21    /** 
     22     * circumvent filter creation 
     23     */ 
    1824    protected function doGetFilter() { } 
    1925     
     26    /** 
     27     * access to protected factory method 
     28     * 
     29     * @return  stubRequestValueErrorFactory 
     30     */ 
    2031    public function getRVEFactory() 
    2132    { 
     
    2940 * @subpackage  ipo_request_broker_annotations_test 
    3041 */ 
    31 class stubAbstractFilterAnnotationTestCase extends UnitTestCase 
     42class stubAbstractFilterAnnotationTestCase extends PHPUnit_Framework_TestCase 
    3243{ 
    3344    /** 
     
    4354    public function setUp() 
    4455    { 
    45         $this->abstractFilterAnnotation = new PartialMockstubAbstractFilterAnnotation(); 
     56        $this->abstractFilterAnnotation = $this->getMock('stubAbstractFilterAnnotation', array('doGetFilter')); 
    4657    } 
    4758 
    4859    /** 
    4960     * test that field name is handled correct 
     61     * 
     62     * @test 
    5063     */ 
    51     public function testFieldName() 
     64    public function fieldName() 
    5265    { 
    5366        $this->assertNull($this->abstractFilterAnnotation->getFieldName()); 
    5467        $this->abstractFilterAnnotation->setFieldName('foo'); 
    55         $this->assertEqual($this->abstractFilterAnnotation->getFieldName(), 'foo'); 
     68        $this->assertEquals('foo', $this->abstractFilterAnnotation->getFieldName()); 
    5669    } 
    5770 
    5871    /** 
    5972     * test that values are set as expected 
     73     * 
     74     * @test 
    6075     */ 
    61     public function testCreateFilterWithDefaultValues() 
     76    public function createFilterWithDefaultValues() 
    6277    { 
    63         $mockFilter = new MockstubFilter(); 
    64         $this->abstractFilterAnnotation->setReturnValue('doGetFilter', $mockFilter); 
    65         $mockFilter->expectOnce('setRequired', array(true)); 
    66         $mockFilter->expectOnce('setDefaultValue', array(null)); 
     78        $mockFilter = $this->getMock('stubFilter'); 
     79        $this->abstractFilterAnnotation->expects($this->once())->method('doGetFilter')->will($this->returnValue($mockFilter)); 
     80        $mockFilter->expects($this->once())->method('setRequired')->with($this->equalTo(true)); 
     81        $mockFilter->expects($this->once())->method('setDefaultValue')->with($this->equalTo(null)); 
    6782        $this->abstractFilterAnnotation->getFilter(); 
    6883    } 
     
    7085    /** 
    7186     * test that values are set as expected 
     87     * 
     88     * @test 
    7289     */ 
    73     public function testCreateFilterWithChangedValues() 
     90    public function createFilterWithChangedValues() 
    7491    { 
    75         $mockFilter = new MockstubFilter(); 
    76         $this->abstractFilterAnnotation->setReturnValue('doGetFilter', $mockFilter); 
     92        $mockFilter = $this->getMock('stubFilter'); 
     93        $this->abstractFilterAnnotation->expects($this->once())->method('doGetFilter')->will($this->returnValue($mockFilter)); 
    7794        $this->abstractFilterAnnotation->setRequired(false); 
    7895        $this->abstractFilterAnnotation->setDefaultValue('foo'); 
    79         $mockFilter->expectOnce('setRequired', array(false)); 
    80         $mockFilter->expectOnce('setDefaultValue', array('foo')); 
     96        $mockFilter->expects($this->once())->method('setRequired')->with($this->equalTo(false)); 
     97        $mockFilter->expects($this->once())->method('setDefaultValue')->with($this->equalTo('foo')); 
    8198        $this->abstractFilterAnnotation->getFilter(); 
    8299    } 
     
    84101    /** 
    85102     * test that the correct RequestErrorValueFactory is created 
     103     * 
     104     * @test 
    86105     */ 
    87     public function testDefaultRequestErrorValueFactory() 
     106    public function defaultRequestErrorValueFactory() 
    88107    { 
    89108        $abstractFilterAnnotation = new TeststubAbstractFilterAnnotation(); 
    90109        $rveFactory = $abstractFilterAnnotation->getRVEFactory(); 
    91         $this->assertIsA($rveFactory, 'stubRequestValueErrorXJConfFactory'); 
     110        $this->assertType('stubRequestValueErrorXJConfFactory', $rveFactory); 
    92111    } 
    93112 
    94113    /** 
    95114     * test that the correct RequestErrorValueFactory is created 
     115     * 
     116     * @test 
    96117     */ 
    97     public function testOtherRequestErrorValueFactory() 
     118    public function otherRequestErrorValueFactory() 
    98119    { 
    99120        $abstractFilterAnnotation = new TeststubAbstractFilterAnnotation(); 
    100         $refClass = new stubReflectionClass('MockstubRequestValueErrorFactory'); 
     121        $class = get_class($this->getMock('stubRequestValueErrorFactory')); 
     122        $refClass = new stubReflectionClass($class); 
    101123        $abstractFilterAnnotation->setRVEFactoryClass($refClass); 
    102124        $rveFactory = $abstractFilterAnnotation->getRVEFactory(); 
    103         $this->assertIsA($rveFactory, 'MockstubRequestValueErrorFactory'); 
     125        $this->assertType($class, $rveFactory); 
    104126    } 
    105127 
    106128    /** 
    107129     * test that mapping is added correct 
     130     * 
     131     * @test 
    108132     */ 
    109     public function testMappedRequestErrorValueFactory() 
     133    public function mappedRequestErrorValueFactory() 
    110134    { 
    111135        $abstractFilterAnnotation = new TeststubAbstractFilterAnnotation(); 
    112136        $abstractFilterAnnotation->setErrorMapping('FIELD_EMPTY=>FOO_EMPTY:TOO_SMALL=>TOO_GREAT'); 
    113137        $rveFactory = $abstractFilterAnnotation->getRVEFactory(); 
    114         $this->assertIsA($rveFactory, 'stubRequestValueErrorFactoryMappingDecorator'); 
    115         $this->assertEqual($rveFactory->getMappings(), array('FIELD_EMPTY' => 'FOO_EMPTY', 
    116                                                              'TOO_SMALL'   => 'TOO_GREAT' 
    117                                                        ) 
     138        $this->assertType('stubRequestValueErrorFactoryMappingDecorator', $rveFactory); 
     139        $this->assertEquals(array('FIELD_EMPTY' => 'FOO_EMPTY', 
     140                                  'TOO_SMALL'   => 'TOO_GREAT' 
     141                            ), 
     142                            $rveFactory->getMappings() 
    118143        ); 
    119144    } 
     
    121146    /** 
    122147     * test that the correct RequestErrorValueFactory is created 
     148     * 
     149     * @test 
     150     * @expectedException  stubRequestBrokerException 
    123151     */ 
    124     public function testWrongRequestErrorValueFactory() 
     152    public function wrongRequestErrorValueFactory() 
    125153    { 
    126154        $abstractFilterAnnotation = new TeststubAbstractFilterAnnotation(); 
    127155        $refClass = new stubReflectionClass('stdClass'); 
    128156        $abstractFilterAnnotation->setRVEFactoryClass($refClass); 
    129         $this->expectException('stubRequestBrokerException'); 
    130157        $abstractFilterAnnotation->getRVEFactory(); 
    131158    } 
  • trunk/src/test/php/net/stubbles/ipo/request/broker/annotations/stubFloatFilterAnnotationTestCase.php

    r1223 r1282  
    1414 * @subpackage  ipo_request_broker_annotations_test 
    1515 */ 
    16 class stubFloatFilterAnnotationTestCase extends UnitTestCase 
     16class stubFloatFilterAnnotationTestCase extends PHPUnit_Framework_TestCase 
    1717{ 
    1818    /** 
     
    3333    /** 
    3434     * test that the correct filter is created 
     35     * 
     36     * @test 
    3537     */ 
    36     public function testInstance() 
     38    public function instance() 
    3739    { 
    3840        $floatFilter = $this->floatFilterAnnotation->getFilter(); 
    39         $this->assertIsA($floatFilter, 'stubFloatFilter'); 
     41        $this->assertType('stubFloatFilter', $floatFilter); 
    4042        $this->assertNull($floatFilter->getMinValidator()); 
    4143        $this->assertNull($floatFilter->getMaxValidator()); 
     
    4446    /** 
    4547     * test that the correct filter is created 
     48     * 
     49     * @test 
    4650     */ 
    47     public function testWithValidators() 
     51    public function withValidators() 
    4852    { 
    4953        $this->floatFilterAnnotation->setMinValue(1); 
    5054        $this->floatFilterAnnotation->setMaxValue(2); 
    5155        $floatFilter = $this->floatFilterAnnotation->getFilter(); 
    52         $this->assertIsA($floatFilter, 'stubFloatFilter'); 
    53         $this->assertIsA($floatFilter->getMinValidator(), 'stubMinNumberValidator'); 
    54         $this->assertIsA($floatFilter->getMaxValidator(), 'stubMaxNumberValidator'); 
    55         $this->assertEqual($floatFilter->getMinValidator()->getValue(), 1); 
    56         $this->assertEqual($floatFilter->getMaxValidator()->getValue(), 2); 
     56        $this->assertType('stubFloatFilter', $floatFilter); 
     57        $this->assertType('stubMinNumberValidator', $floatFilter->getMinValidator()); 
     58        $this->assertType('stubMaxNumberValidator', $floatFilter->getMaxValidator()); 
     59        $this->assertEquals(1, $floatFilter->getMinValidator()->getValue()); 
     60        $this->assertEquals(2, $floatFilter->getMaxValidator()->getValue()); 
    5761    } 
    5862} 
  • trunk/src/test/php/net/stubbles/ipo/request/broker/annotations/stubHTTPURLFilterAnnotationTestCase.php

    r1223 r1282  
    1414 * @subpackage  ipo_request_broker_annotations_test 
    1515 */ 
    16 class stubHTTPURLFilterAnnotationTestCase extends UnitTestCase 
     16class stubHTTPURLFilterAnnotationTestCase extends PHPUnit_Framework_TestCase 
    1717{ 
    1818    /** 
     
    3333    /** 
    3434     * test that the correct filter is created 
     35     * 
     36     * @test 
    3537     */ 
    36     public function testInstance() 
     38    public function instance() 
    3739    { 
    3840        $httpURLFilter = $this->httpURLFilterAnnotation->getFilter(); 
    39         $this->assertIsA($httpURLFilter, 'stubHTTPURLFilter'); 
     41        $this->assertType('stubHTTPURLFilter', $httpURLFilter); 
    4042        $this->assertFalse($httpURLFilter->isDNSCheckEnabled()); 
    4143    } 
     
    4345    /** 
    4446     * test that the correct filter is created 
     47     * 
     48     * @test 
    4549     */ 
    46     public function testWithDNSCheckEnabled() 
     50    public function withDNSCheckEnabled() 
    4751    { 
    4852        $this->httpURLFilterAnnotation->setCheckDNS(true); 
    4953        $httpURLFilter = $this->httpURLFilterAnnotation->getFilter(); 
    50         $this->assertIsA($httpURLFilter, 'stubHTTPURLFilter'); 
     54        $this->assertType('stubHTTPURLFilter', $httpURLFilter); 
    5155        $this->assertTrue($httpURLFilter->isDNSCheckEnabled()); 
    5256    } 
  • trunk/src/test/php/net/stubbles/ipo/request/broker/annotations/stubIntegerFilterAnnotationTestCase.php

    r1223 r1282  
    1414 * @subpackage  ipo_request_broker_annotations_test 
    1515 */ 
    16 class stubIntegerFilterAnnotationTestCase extends UnitTestCase 
     16class stubIntegerFilterAnnotationTestCase extends PHPUnit_Framework_TestCase 
    1717{ 
    1818    /** 
     
    3333    /** 
    3434     * test that the correct filter is created 
     35     * 
     36     * @test 
    3537     */ 
    36     public function testInstance() 
     38    public function instance() 
    3739    { 
    3840        $integerFilter = $this->integerFilterAnnotation->getFilter(); 
    39         $this->assertIsA($integerFilter, 'stubIntegerFilter'); 
     41        $this->assertType('stubIntegerFilter', $integerFilter); 
    4042        $this->assertNull($integerFilter->getMinValidator()); 
    4143        $this->assertNull($integerFilter->getMaxValidator()); 
     
    4446    /** 
    4547     * test that the correct filter is created 
     48     * 
     49     * @test 
    4650     */ 
    47     public function testWithValidators() 
     51    public function withValidators() 
    4852    { 
    4953        $this->integerFilterAnnotation->setMinValue(1); 
    5054        $this->integerFilterAnnotation->setMaxValue(2); 
    5155        $integerFilter = $this->integerFilterAnnotation->getFilter(); 
    52         $this->assertIsA($integerFilter, 'stubIntegerFilter'); 
    53         $this->assertIsA($integerFilter->getMinValidator(), 'stubMinNumberValidator'); 
    54         $this->assertIsA($integerFilter->getMaxValidator(), 'stubMaxNumberValidator'); 
    55         $this->assertEqual($integerFilter->getMinValidator()->getValue(), 1); 
    56         $this->assertEqual($integerFilter->getMaxValidator()->getValue(), 2); 
     56        $this->assertType('stubIntegerFilter', $integerFilter); 
     57        $this->assertType('stubMinNumberValidator', $integerFilter->getMinValidator()); 
     58        $this->assertType('stubMaxNumberValidator', $integerFilter->getMaxValidator()); 
     59        $this->assertEquals(1, $integerFilter->getMinValidator()->getValue()); 
     60        $this->assertEquals(2, $integerFilter->getMaxValidator()->getValue()); 
    5761    } 
    5862} 
  • trunk/src/test/php/net/stubbles/ipo/request/broker/annotations/stubMailFilterAnnotationTestCase.php

    r1223 r1282  
    1414 * @subpackage  ipo_request_broker_annotations_test 
    1515 */ 
    16 class stubMailFilterAnnotationTestCase extends UnitTestCase 
     16class stubMailFilterAnnotationTestCase extends PHPUnit_Framework_TestCase 
    1717{ 
    1818    /** 
    1919     * test that the correct filter is created 
     20     * 
     21     * @test 
    2022     */ 
    21     public function testInstance() 
     23    public function instance() 
    2224    { 
    2325        $mailFilterAnnotation = new stubMailFilterAnnotation(); 
    2426        $mailFilter           = $mailFilterAnnotation->getFilter(); 
    25         $this->assertIsA($mailFilter, 'stubMailFilter'); 
     27        $this->assertType('stubMailFilter', $mailFilter); 
    2628    } 
    2729} 
  • trunk/src/test/php/net/stubbles/ipo/request/broker/annotations/stubPasswordFilterAnnotationTestCase.php

    r1223 r1282  
    1414 * @subpackage  ipo_request_broker_annotations_test 
    1515 */ 
    16 class stubPasswordFilterAnnotationTestCase extends UnitTestCase 
     16class stubPasswordFilterAnnotationTestCase extends PHPUnit_Framework_TestCase 
    1717{ 
    1818    /** 
     
    3333    /** 
    3434     * test that the correct filter is created 
     35     * 
     36     * @test 
    3537     */ 
    36     public function testInstance() 
     38    public function instance() 
    3739    { 
    3840        $passwordFilter = $this->passwordFilterAnnotation->getFilter(); 
    39         $this->assertIsA($passwordFilter, 'stubPasswordFilter'); 
    40         $this->assertIsA($passwordFilter->getMinLengthValidator(), 'stubMinLengthValidator'); 
    41         $this->assertEqual($passwordFilter->getMinLengthValidator()->getValue(), 6); 
     41        $this->assertType('stubPasswordFilter', $passwordFilter); 
     42        $this->assertType('stubMinLengthValidator', $passwordFilter->getMinLengthValidator()); 
     43        $this->assertEquals(6, $passwordFilter->getMinLengthValidator()->getValue()); 
    4244        $this->assertNull($passwordFilter->getEncoder()); 
    4345    } 
     
    4547    /** 
    4648     * test that the correct filter is created 
     49     * 
     50     * @test 
    4751     */ 
    48     public function testWithValidators() 
     52    public function withValidators() 
    4953    { 
    5054        $this->passwordFilterAnnotation->setMinLength(8); 
    5155        $passwordFilter = $this->passwordFilterAnnotation->getFilter(); 
    52         $this->assertIsA($passwordFilter, 'stubPasswordFilter'); 
    53         $this->assertIsA($passwordFilter->getMinLengthValidator(), 'stubMinLengthValidator'); 
    54         $this->assertEqual($passwordFilter->getMinLengthValidator()->getValue(), 8); 
     56        $this->assertType('stubPasswordFilter', $passwordFilter); 
     57        $this->assertType('stubMinLengthValidator', $passwordFilter->getMinLengthValidator()); 
     58        $this->assertEquals(8, $passwordFilter->getMinLengthValidator()->getValue()); 
    5559        $this->assertNull($passwordFilter->getEncoder()); 
    5660    } 
     
    5862    /** 
    5963     * assert that the encoder is set correct 
     64     * 
     65     * @test 
    6066     */ 
    61     public function testWithEncoder() 
     67    public function withEncoder() 
    6268    { 
    6369        $this->passwordFilterAnnotation->setEncoder(new stubReflectionClass('net::stubbles::php::string::stubMd5Encoder')); 
    6470        $passwordFilter = $this->passwordFilterAnnotation->getFilter(); 
    65         $this->assertIsA($passwordFilter, 'stubPasswordFilter'); 
    66         $this->assertIsA($passwordFilter->getEncoder(), 'stubMd5Encoder'); 
     71        $this->assertType('stubPasswordFilter', $passwordFilter); 
     72        $this->assertType('stubMd5Encoder', $passwordFilter->getEncoder()); 
    6773    } 
    6874} 
  • trunk/src/test/php/net/stubbles/ipo/request/broker/annotations/stubStringFilterAnnotationTestCase.php

    r1223 r1282  
    1414 * @subpackage  ipo_request_broker_annotations_test 
    1515 */ 
    16 class stubStringFilterAnnotationTestCase extends UnitTestCase 
     16class stubStringFilterAnnotationTestCase extends PHPUnit_Framework_TestCase 
    1717{ 
    1818    /** 
     
    3333    /** 
    3434     * test that the correct filter is created 
     35     * 
     36     * @test 
    3537     */ 
    36     public function testInstance() 
     38    public function instance() 
    3739    { 
    3840        $stringFilter = $this->stringFilterAnnotation->getFilter(); 
    39         $this->assertIsA($stringFilter, 'stubStringFilter'); 
     41        $this->assertType('stubStringFilter', $stringFilter); 
    4042        $this->assertNull($stringFilter->getMinLengthValidator()); 
    4143        $this->assertNull($stringFilter->getMaxLengthValidator()); 
    42         $this->assertIsA($stringFilter->getRegexValidator(), 'stubRegexValidator'); 
    43         $this->assertEqual($stringFilter->getRegexValidator()->getValue(), ''); 
     44        $this->assertType('stubRegexValidator', $stringFilter->getRegexValidator()); 
     45        $this->assertEquals('', $stringFilter->getRegexValidator()->getValue()); 
    4446    } 
    4547 
    4648    /** 
    4749     * test that the correct filter is created 
     50     * 
     51     * @test 
    4852     */ 
    49     public function testWithValidators() 
     53    public function withValidators() 
    5054    { 
    5155        $this->stringFilterAnnotation->setMinLength(1); 
     
    5357        $this->stringFilterAnnotation->setRegex('/foo/'); 
    5458        $stringFilter = $this->stringFilterAnnotation->getFilter(); 
    55         $this->assertIsA($stringFilter, 'stubStringFilter'); 
    56         $this->assertIsA($stringFilter->getMinLengthValidator(), 'stubMinLengthValidator'); 
    57         $this->assertIsA($stringFilter->getMaxLengthValidator(), 'stubMaxLengthValidator'); 
    58         $this->assertEqual($stringFilter->getMinLengthValidator()->getValue(), 1); 
    59         $this->assertEqual($stringFilter->getMaxLengthValidator()->getValue(), 2); 
    60         $this->assertIsA($stringFilter->getRegexValidator(), 'stubRegexValidator'); 
    61         $this->assertEqual($stringFilter->getRegexValidator()->getValue(), '/foo/'); 
     59        $this->assertType('stubStringFilter', $stringFilter); 
     60        $this->assertType('stubMinLengthValidator', $stringFilter->getMinLengthValidator()); 
     61        $this->assertType('stubMaxLengthValidator', $stringFilter->getMaxLengthValidator()); 
     62        $this->assertEquals(1, $stringFilter->getMinLengthValidator()->getValue()); 
     63        $this->assertEquals(2, $stringFilter->getMaxLengthValidator()->getValue()); 
     64        $this->assertType('stubRegexValidator', $stringFilter->getRegexValidator()); 
     65        $this->assertEquals('/foo/', $stringFilter->getRegexValidator()->getValue()); 
    6266    } 
    6367 
    6468    /** 
    6569     * assert that the encoder is set correct 
     70     * 
     71     * @test 
    6672     */ 
    67     public function testWithEncoder() 
     73    public function withEncoder() 
    6874    { 
    6975        $this->stringFilterAnnotation->setEncoder(new stubReflectionClass('net::stubbles::php::string::stubMd5Encoder')); 
    7076        $stringFilter = $this->stringFilterAnnotation->getFilter(); 
    71         $this->assertIsA($stringFilter->getEncoder(), 'stubMd5Encoder'); 
    72         $this->assertEqual($stringFilter->getEncoderMode(), stubStringEncoder::MODE_DECODE); 
     77        $this->assertType('stubMd5Encoder', $stringFilter->getEncoder()); 
     78        $this->assertEquals(stubStringEncoder::MODE_DECODE, $stringFilter->getEncoderMode()); 
    7379        $this->stringFilterAnnotation->setEncoderMode(stubStringEncoder::MODE_ENCODE); 
    7480        $stringFilter = $this->stringFilterAnnotation->getFilter(); 
    75         $this->assertIsA($stringFilter->getEncoder(), 'stubMd5Encoder'); 
    76         $this->assertEqual($stringFilter->getEncoderMode(), stubStringEncoder::MODE_ENCODE); 
     81        $this->assertType('stubMd5Encoder', $stringFilter->getEncoder()); 
     82        $this->assertEquals(stubStringEncoder::MODE_ENCODE, $stringFilter->getEncoderMode()); 
    7783    } 
    7884 
    7985    /** 
    8086     * test that finish() works as expected 
     87     * 
     88     * @test 
     89     * @expectedException  ReflectionException 
    8190     */ 
    82     public function testFinishWithoutRegex() 
     91    public function finishWithoutRegex() 
    8392    { 
    84         $this->stringFilterAnnotation->setRegex(); 
    85         $this->expectException('ReflectionException'); 
     93        $this->stringFilterAnnotation->setRegex(''); 
    8694        $this->stringFilterAnnotation->finish(); 
    8795    } 
     
    8997    /** 
    9098     * test that finish() works as expected 
     99     * 
     100     * @test 
     101     * @expectedException  ReflectionException 
    91102     */ 
    92     public function testFinishWithWrongEncoderMode() 
     103    public function finishWithWrongEncoderMode() 
    93104    { 
     105        $this->stringFilterAnnotation->setMinLength(1); 
     106        $this->stringFilterAnnotation->setMaxLength(2); 
     107        $this->stringFilterAnnotation->setRegex('/foo/'); 
    94108        $this->stringFilterAnnotation->setEncoder(new stubReflectionClass('net::stubbles::php::string::stubMd5Encoder')); 
    95109        $this->stringFilterAnnotation->setEncoderMode('invalid'); 
    96         $this->expectException('ReflectionException'); 
    97110        $this->stringFilterAnnotation->finish(); 
    98111    } 
  • trunk/src/test/php/net/stubbles/ipo/request/broker/annotations/stubTextFilterAnnotationTestCase.php

    r1223 r1282  
    1414 * @subpackage  ipo_request_broker_annotations_test 
    1515 */ 
    16 class stubTextFilterAnnotationTestCase extends UnitTestCase 
     16class stubTextFilterAnnotationTestCase extends PHPUnit_Framework_TestCase 
    1717{ 
    1818    /** 
     
    3333    /** 
    3434     * test that the correct filter is created 
     35     * 
     36     * @test 
    3537     */ 
    36     public function testInstance() 
     38    public function instance() 
    3739    { 
    3840        $textFilter = $this->textFilterAnnotation->getFilter(); 
    39         $this->assertIsA($textFilter, 'stubTextFilter'); 
     41        $this->assertType('stubTextFilter', $textFilter); 
    4042        $this->assertNull($textFilter->getMinLengthValidator()); 
    4143        $this->assertNull($textFilter->getMaxLengthValidator()); 
    42         $this->assertEqual($textFilter->getAllowedTags(), array()); 
     44        $this->assertEquals(array(), $textFilter->getAllowedTags()); 
    4345    } 
    4446 
    4547    /** 
    4648     * test that the correct filter is created 
     49     * 
     50     * @test 
    4751     */ 
    48     public function testWithValidators() 
     52    public function withValidators() 
    4953    { 
    5054        $this->textFilterAnnotation->setMinLength(1); 
     
    5256        $this->textFilterAnnotation->setAllowedTags('foo, bar, baz'); 
    5357        $textFilter = $this->textFilterAnnotation->getFilter(); 
    54         $this->assertIsA($textFilter, 'stubTextFilter'); 
    55         $this->assertIsA($textFilter->getMinLengthValidator(), 'stubMinLengthValidator'); 
    56         $this->assertIsA($textFilter->getMaxLengthValidator(), 'stubMaxLengthValidator'); 
    57         $this->assertEqual($textFilter->getMinLengthValidator()->getValue(), 1); 
    58         $this->assertEqual($textFilter->getMaxLengthValidator()->getValue(), 2); 
    59         $this->assertEqual($textFilter->getAllowedTags(), array('foo', 'bar', 'baz')); 
     58        $this->assertType('stubTextFilter', $textFilter); 
     59        $this->assertType('stubMinLengthValidator', $textFilter->getMinLengthValidator()); 
     60        $this->assertType('stubMaxLengthValidator', $textFilter->getMaxLengthValidator()); 
     61        $this->assertEquals(1, $textFilter->getMinLengthValidator()->getValue()); 
     62        $this->assertEquals(2, $textFilter->getMaxLengthValidator()->getValue()); 
     63        $this->assertEquals(array('foo', 'bar', 'baz'), $textFilter->getAllowedTags()); 
    6064    } 
    6165 
    6266    /** 
    6367     * assert that the encoder is set correct 
     68     * 
     69     * @test 
    6470     */ 
    65     public function testWithEncoder() 
     71    public function withEncoder() 
    6672    { 
    6773        $this->textFilterAnnotation->setEncoder(new stubReflectionClass('net::stubbles::php::string::stubMd5Encoder')); 
    6874        $textFilter = $this->textFilterAnnotation->getFilter(); 
    69         $this->assertIsA($textFilter->getEncoder(), 'stubMd5Encoder'); 
    70         $this->assertEqual($textFilter->getEncoderMode(), stubStringEncoder::MODE_DECODE); 
     75        $this->assertType('stubMd5Encoder', $textFilter->getEncoder()); 
     76        $this->assertEquals(stubStringEncoder::MODE_DECODE, $textFilter->getEncoderMode()); 
    7177        $this->textFilterAnnotation->setEncoderMode(stubStringEncoder::MODE_ENCODE); 
    7278        $textFilter = $this->textFilterAnnotation->getFilter(); 
    73         $this->assertIsA($textFilter->getEncoder(), 'stubMd5Encoder'); 
    74         $this->assertEqual($textFilter->getEncoderMode(), stubStringEncoder::MODE_ENCODE); 
     79        $this->assertType('stubMd5Encoder', $textFilter->getEncoder()); 
     80        $this->assertEquals(stubStringEncoder::MODE_ENCODE, $textFilter->getEncoderMode()); 
    7581    } 
    7682 
    7783    /** 
    7884     * test that finish() works as expected 
     85     * 
     86     * @test 
     87     * @expectedException  ReflectionException 
    7988     */ 
    80     public function testFinishWithWrongEncoderMode() 
     89    public function finishWithWrongEncoderMode() 
    8190    { 
    8291        $this->textFilterAnnotation->setEncoder(new stubReflectionClass('net::stubbles::php::string::stubMd5Encoder')); 
    8392        $this->textFilterAnnotation->setEncoderMode('invalid'); 
    84         $this->expectException('ReflectionException'); 
    8593        $this->textFilterAnnotation->finish(); 
    8694    } 
  • trunk/src/test/php/net/stubbles/ipo/request/broker/stubRequestBrokerTestCase.php

    r1241 r1282  
    88 */ 
    99stubClassLoader::load('net::stubbles::ipo::request::broker::stubRequestBroker'); 
    10 Mock::generate('stubRequest'); 
    1110require_once dirname(__FILE__) . '/TestBrokerClasses.php'; 
    1211/** 
     
    1615 * @subpackage  ipo_request_broker_test 
    1716 */ 
    18 class stubRequestBrokerTestCase extends UnitTestCase 
     17class stubRequestBrokerTestCase extends PHPUnit_Framework_TestCase 
    1918{ 
    2019    /** 
     
    2726     * mocked request instance 
    2827     * 
    29      * @var  SimpleMock 
     28     * @var  PHPUnit_Framework_MockObject_MockObject 
    3029     */ 
    3130    protected $mockRequest; 
     
    3736    { 
    3837        $this->requestBroker = new stubRequestBroker(); 
    39         $this->mockRequest   = new MockstubRequest(); 
     38        $this->mockRequest   = $this->getMock('stubRequest'); 
    4039    } 
    4140 
    4241    /** 
    4342     * test that an illegal object throws an stubIllegalArgumentException 
     43     * 
     44     * @test 
     45     * @expectedException  stubIllegalArgumentException 
    4446     */ 
    45     public function testIllegalObject() 
     47    public function illegalObject() 
    4648    { 
    47         $this->expectException('stubIllegalArgumentException'); 
    4849        $this->requestBroker->process($this->mockRequest, 'foo'); 
    4950    } 
     
    5152    /** 
    5253     * test broking with a class that is not an instance of net::stubbles::lang::stubObject 
     54     * 
     55     * @test 
    5356     */ 
    54     public function testWithClassThatIsNotInstanceOfStubObject() 
     57    public function withClassThatIsNotInstanceOfStubObject() 
    5558    { 
    56         $this->mockRequest->expectAt(0, 'getFilteredValue', array('*', 'foo')); 
    57         $this->mockRequest->expectAt(1, 'getFilteredValue', array('*', 'bar')); 
    58         $this->mockRequest->setReturnValueAt(0, 'getFilteredValue', 'foo'); 
    59         $this->mockRequest->setReturnValueAt(1, 'getFilteredValue', 'bar'); 
    60         $this->mockRequest->setReturnValueAt(0, 'hasValueError', false); 
    61         $this->mockRequest->setReturnValueAt(1, 'hasValueError', false); 
    62         $this->mockRequest->expectCallCount('getFilteredValue', 2); 
     59        $this->mockRequest->expects($this->exactly(2)) 
     60                          ->method('getFilteredValue') 
     61                          ->will($this->onConsecutiveCalls('foo', 'bar')); 
     62        $this->mockRequest->expects($this->exactly(2)) 
     63                          ->method('hasValueError') 
     64                          ->will($this->returnValue(false)); 
    6365        $testClass = new TestBrokerClass(); 
    6466        $this->requestBroker->process($this->mockRequest, $testClass); 
    65         $this->assertEqual($testClass->foo, 'foo'); 
    66         $this->assertEqual($testClass->getBar(), 'bar'); 
     67        $this->assertEquals('foo', $testClass->foo); 
     68        $this->assertEquals('bar', $testClass->getBar()); 
    6769        $this->assertNull($testClass->getBaz()); 
    6870        $this->assertNull(TestBrokerClass::$dummy); 
     
    7173    /** 
    7274     * test broking with a class that is an instance of net::stubbles::lang::stubObject 
     75     * 
     76     * @test 
    7377     */ 
    74     public function testWithClassThatIsInstanceOfStubObject() 
     78    public function withClassThatIsInstanceOfStubObject() 
    7579    { 
    76         $this->mockRequest->expectAt(0, 'getFilteredValue', array('*', 'prefix_foo')); 
    77         $this->mockRequest->expectAt(1, 'getFilteredValue', array('*', 'prefix_bar')); 
    78         $this->mockRequest->setReturnValueAt(0, 'getFilteredValue', 'foo'); 
    79         $this->mockRequest->setReturnValueAt(1, 'getFilteredValue', 'bar'); 
    80         $this->mockRequest->setReturnValueAt(0, 'hasValueError', false); 
    81         $this->mockRequest->setReturnValueAt(1, 'hasValueError', false); 
    82         $this->mockRequest->expectCallCount('getFilteredValue', 2); 
     80        $this->mockRequest->expects($this->exactly(2)) 
     81                          ->method('getFilteredValue') 
     82                          ->will($this->onConsecutiveCalls('foo', 'bar')); 
     83        $this->mockRequest->expects($this->exactly(2)) 
     84                          ->method('hasValueError') 
     85                          ->will($this->returnValue(false)); 
    8386        $testClass = new TestBrokerObject(); 
    8487        $this->requestBroker->process($this->mockRequest, $testClass, 'prefix_'); 
    85         $this->assertEqual($testClass->foo, 'foo'); 
    86         $this->assertEqual($testClass->getBar(), 'bar'); 
     88        $this->assertEquals('foo', $testClass->foo); 
     89        $this->assertEquals('bar', $testClass->getBar()); 
    8790        $this->assertNull($testClass->getBaz()); 
    8891        $this->assertNull(TestBrokerObject::$dummy);