Changeset 1282
- Timestamp:
- 01/22/08 18:40:54 (8 months ago)
- Files:
-
- trunk/src/main/php/net/stubbles/ipo/request/broker/annotations/stubStringFilterAnnotation.php (modified) (1 diff)
- trunk/src/test/php/net/stubbles/ipo/IPOTestSuite.php (modified) (1 diff)
- trunk/src/test/php/net/stubbles/ipo/request/broker/annotations/stubAbstractFilterAnnotationTestCase.php (modified) (6 diffs)
- trunk/src/test/php/net/stubbles/ipo/request/broker/annotations/stubFloatFilterAnnotationTestCase.php (modified) (3 diffs)
- trunk/src/test/php/net/stubbles/ipo/request/broker/annotations/stubHTTPURLFilterAnnotationTestCase.php (modified) (3 diffs)
- trunk/src/test/php/net/stubbles/ipo/request/broker/annotations/stubIntegerFilterAnnotationTestCase.php (modified) (3 diffs)
- trunk/src/test/php/net/stubbles/ipo/request/broker/annotations/stubMailFilterAnnotationTestCase.php (modified) (1 diff)
- trunk/src/test/php/net/stubbles/ipo/request/broker/annotations/stubPasswordFilterAnnotationTestCase.php (modified) (4 diffs)
- trunk/src/test/php/net/stubbles/ipo/request/broker/annotations/stubStringFilterAnnotationTestCase.php (modified) (4 diffs)
- trunk/src/test/php/net/stubbles/ipo/request/broker/annotations/stubTextFilterAnnotationTestCase.php (modified) (3 diffs)
- trunk/src/test/php/net/stubbles/ipo/request/broker/stubRequestBrokerTestCase.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/main/php/net/stubbles/ipo/request/broker/annotations/stubStringFilterAnnotation.php
r1223 r1282 61 61 public function finish() 62 62 { 63 if (null == =$this->regex) {63 if (null == $this->regex) { 64 64 throw new ReflectionException('Can not use ' . $this->getClassName() . ' without setting the regular expression via regex property.'); 65 65 } trunk/src/test/php/net/stubbles/ipo/IPOTestSuite.php
r1274 r1282 31 31 $suite->addTestFile($dir . '/request/stubRequestValueErrorTestCase.php'); 32 32 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'); 42 42 43 43 $suite->addTestFile($dir . '/request/filters/stubFloatFilterTestCase.php'); trunk/src/test/php/net/stubbles/ipo/request/broker/annotations/stubAbstractFilterAnnotationTestCase.php
r1223 r1282 11 11 'net::stubbles::ipo::request::stubRequestValueErrorFactory' 12 12 ); 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 */ 16 19 class TeststubAbstractFilterAnnotation extends stubAbstractFilterAnnotation 17 20 { 21 /** 22 * circumvent filter creation 23 */ 18 24 protected function doGetFilter() { } 19 25 26 /** 27 * access to protected factory method 28 * 29 * @return stubRequestValueErrorFactory 30 */ 20 31 public function getRVEFactory() 21 32 { … … 29 40 * @subpackage ipo_request_broker_annotations_test 30 41 */ 31 class stubAbstractFilterAnnotationTestCase extends UnitTestCase42 class stubAbstractFilterAnnotationTestCase extends PHPUnit_Framework_TestCase 32 43 { 33 44 /** … … 43 54 public function setUp() 44 55 { 45 $this->abstractFilterAnnotation = new PartialMockstubAbstractFilterAnnotation();56 $this->abstractFilterAnnotation = $this->getMock('stubAbstractFilterAnnotation', array('doGetFilter')); 46 57 } 47 58 48 59 /** 49 60 * test that field name is handled correct 61 * 62 * @test 50 63 */ 51 public function testFieldName()64 public function fieldName() 52 65 { 53 66 $this->assertNull($this->abstractFilterAnnotation->getFieldName()); 54 67 $this->abstractFilterAnnotation->setFieldName('foo'); 55 $this->assertEqual ($this->abstractFilterAnnotation->getFieldName(), 'foo');68 $this->assertEquals('foo', $this->abstractFilterAnnotation->getFieldName()); 56 69 } 57 70 58 71 /** 59 72 * test that values are set as expected 73 * 74 * @test 60 75 */ 61 public function testCreateFilterWithDefaultValues()76 public function createFilterWithDefaultValues() 62 77 { 63 $mockFilter = new MockstubFilter();64 $this->abstractFilterAnnotation-> setReturnValue('doGetFilter', $mockFilter);65 $mockFilter->expect Once('setRequired', array(true));66 $mockFilter->expect Once('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)); 67 82 $this->abstractFilterAnnotation->getFilter(); 68 83 } … … 70 85 /** 71 86 * test that values are set as expected 87 * 88 * @test 72 89 */ 73 public function testCreateFilterWithChangedValues()90 public function createFilterWithChangedValues() 74 91 { 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)); 77 94 $this->abstractFilterAnnotation->setRequired(false); 78 95 $this->abstractFilterAnnotation->setDefaultValue('foo'); 79 $mockFilter->expect Once('setRequired', array(false));80 $mockFilter->expect Once('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')); 81 98 $this->abstractFilterAnnotation->getFilter(); 82 99 } … … 84 101 /** 85 102 * test that the correct RequestErrorValueFactory is created 103 * 104 * @test 86 105 */ 87 public function testDefaultRequestErrorValueFactory()106 public function defaultRequestErrorValueFactory() 88 107 { 89 108 $abstractFilterAnnotation = new TeststubAbstractFilterAnnotation(); 90 109 $rveFactory = $abstractFilterAnnotation->getRVEFactory(); 91 $this->assert IsA($rveFactory, 'stubRequestValueErrorXJConfFactory');110 $this->assertType('stubRequestValueErrorXJConfFactory', $rveFactory); 92 111 } 93 112 94 113 /** 95 114 * test that the correct RequestErrorValueFactory is created 115 * 116 * @test 96 117 */ 97 public function testOtherRequestErrorValueFactory()118 public function otherRequestErrorValueFactory() 98 119 { 99 120 $abstractFilterAnnotation = new TeststubAbstractFilterAnnotation(); 100 $refClass = new stubReflectionClass('MockstubRequestValueErrorFactory'); 121 $class = get_class($this->getMock('stubRequestValueErrorFactory')); 122 $refClass = new stubReflectionClass($class); 101 123 $abstractFilterAnnotation->setRVEFactoryClass($refClass); 102 124 $rveFactory = $abstractFilterAnnotation->getRVEFactory(); 103 $this->assert IsA($rveFactory, 'MockstubRequestValueErrorFactory');125 $this->assertType($class, $rveFactory); 104 126 } 105 127 106 128 /** 107 129 * test that mapping is added correct 130 * 131 * @test 108 132 */ 109 public function testMappedRequestErrorValueFactory()133 public function mappedRequestErrorValueFactory() 110 134 { 111 135 $abstractFilterAnnotation = new TeststubAbstractFilterAnnotation(); 112 136 $abstractFilterAnnotation->setErrorMapping('FIELD_EMPTY=>FOO_EMPTY:TOO_SMALL=>TOO_GREAT'); 113 137 $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() 118 143 ); 119 144 } … … 121 146 /** 122 147 * test that the correct RequestErrorValueFactory is created 148 * 149 * @test 150 * @expectedException stubRequestBrokerException 123 151 */ 124 public function testWrongRequestErrorValueFactory()152 public function wrongRequestErrorValueFactory() 125 153 { 126 154 $abstractFilterAnnotation = new TeststubAbstractFilterAnnotation(); 127 155 $refClass = new stubReflectionClass('stdClass'); 128 156 $abstractFilterAnnotation->setRVEFactoryClass($refClass); 129 $this->expectException('stubRequestBrokerException');130 157 $abstractFilterAnnotation->getRVEFactory(); 131 158 } trunk/src/test/php/net/stubbles/ipo/request/broker/annotations/stubFloatFilterAnnotationTestCase.php
r1223 r1282 14 14 * @subpackage ipo_request_broker_annotations_test 15 15 */ 16 class stubFloatFilterAnnotationTestCase extends UnitTestCase16 class stubFloatFilterAnnotationTestCase extends PHPUnit_Framework_TestCase 17 17 { 18 18 /** … … 33 33 /** 34 34 * test that the correct filter is created 35 * 36 * @test 35 37 */ 36 public function testInstance()38 public function instance() 37 39 { 38 40 $floatFilter = $this->floatFilterAnnotation->getFilter(); 39 $this->assert IsA($floatFilter, 'stubFloatFilter');41 $this->assertType('stubFloatFilter', $floatFilter); 40 42 $this->assertNull($floatFilter->getMinValidator()); 41 43 $this->assertNull($floatFilter->getMaxValidator()); … … 44 46 /** 45 47 * test that the correct filter is created 48 * 49 * @test 46 50 */ 47 public function testWithValidators()51 public function withValidators() 48 52 { 49 53 $this->floatFilterAnnotation->setMinValue(1); 50 54 $this->floatFilterAnnotation->setMaxValue(2); 51 55 $floatFilter = $this->floatFilterAnnotation->getFilter(); 52 $this->assert IsA($floatFilter, 'stubFloatFilter');53 $this->assert IsA($floatFilter->getMinValidator(), 'stubMinNumberValidator');54 $this->assert IsA($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()); 57 61 } 58 62 } trunk/src/test/php/net/stubbles/ipo/request/broker/annotations/stubHTTPURLFilterAnnotationTestCase.php
r1223 r1282 14 14 * @subpackage ipo_request_broker_annotations_test 15 15 */ 16 class stubHTTPURLFilterAnnotationTestCase extends UnitTestCase16 class stubHTTPURLFilterAnnotationTestCase extends PHPUnit_Framework_TestCase 17 17 { 18 18 /** … … 33 33 /** 34 34 * test that the correct filter is created 35 * 36 * @test 35 37 */ 36 public function testInstance()38 public function instance() 37 39 { 38 40 $httpURLFilter = $this->httpURLFilterAnnotation->getFilter(); 39 $this->assert IsA($httpURLFilter, 'stubHTTPURLFilter');41 $this->assertType('stubHTTPURLFilter', $httpURLFilter); 40 42 $this->assertFalse($httpURLFilter->isDNSCheckEnabled()); 41 43 } … … 43 45 /** 44 46 * test that the correct filter is created 47 * 48 * @test 45 49 */ 46 public function testWithDNSCheckEnabled()50 public function withDNSCheckEnabled() 47 51 { 48 52 $this->httpURLFilterAnnotation->setCheckDNS(true); 49 53 $httpURLFilter = $this->httpURLFilterAnnotation->getFilter(); 50 $this->assert IsA($httpURLFilter, 'stubHTTPURLFilter');54 $this->assertType('stubHTTPURLFilter', $httpURLFilter); 51 55 $this->assertTrue($httpURLFilter->isDNSCheckEnabled()); 52 56 } trunk/src/test/php/net/stubbles/ipo/request/broker/annotations/stubIntegerFilterAnnotationTestCase.php
r1223 r1282 14 14 * @subpackage ipo_request_broker_annotations_test 15 15 */ 16 class stubIntegerFilterAnnotationTestCase extends UnitTestCase16 class stubIntegerFilterAnnotationTestCase extends PHPUnit_Framework_TestCase 17 17 { 18 18 /** … … 33 33 /** 34 34 * test that the correct filter is created 35 * 36 * @test 35 37 */ 36 public function testInstance()38 public function instance() 37 39 { 38 40 $integerFilter = $this->integerFilterAnnotation->getFilter(); 39 $this->assert IsA($integerFilter, 'stubIntegerFilter');41 $this->assertType('stubIntegerFilter', $integerFilter); 40 42 $this->assertNull($integerFilter->getMinValidator()); 41 43 $this->assertNull($integerFilter->getMaxValidator()); … … 44 46 /** 45 47 * test that the correct filter is created 48 * 49 * @test 46 50 */ 47 public function testWithValidators()51 public function withValidators() 48 52 { 49 53 $this->integerFilterAnnotation->setMinValue(1); 50 54 $this->integerFilterAnnotation->setMaxValue(2); 51 55 $integerFilter = $this->integerFilterAnnotation->getFilter(); 52 $this->assert IsA($integerFilter, 'stubIntegerFilter');53 $this->assert IsA($integerFilter->getMinValidator(), 'stubMinNumberValidator');54 $this->assert IsA($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()); 57 61 } 58 62 } trunk/src/test/php/net/stubbles/ipo/request/broker/annotations/stubMailFilterAnnotationTestCase.php
r1223 r1282 14 14 * @subpackage ipo_request_broker_annotations_test 15 15 */ 16 class stubMailFilterAnnotationTestCase extends UnitTestCase16 class stubMailFilterAnnotationTestCase extends PHPUnit_Framework_TestCase 17 17 { 18 18 /** 19 19 * test that the correct filter is created 20 * 21 * @test 20 22 */ 21 public function testInstance()23 public function instance() 22 24 { 23 25 $mailFilterAnnotation = new stubMailFilterAnnotation(); 24 26 $mailFilter = $mailFilterAnnotation->getFilter(); 25 $this->assert IsA($mailFilter, 'stubMailFilter');27 $this->assertType('stubMailFilter', $mailFilter); 26 28 } 27 29 } trunk/src/test/php/net/stubbles/ipo/request/broker/annotations/stubPasswordFilterAnnotationTestCase.php
r1223 r1282 14 14 * @subpackage ipo_request_broker_annotations_test 15 15 */ 16 class stubPasswordFilterAnnotationTestCase extends UnitTestCase16 class stubPasswordFilterAnnotationTestCase extends PHPUnit_Framework_TestCase 17 17 { 18 18 /** … … 33 33 /** 34 34 * test that the correct filter is created 35 * 36 * @test 35 37 */ 36 public function testInstance()38 public function instance() 37 39 { 38 40 $passwordFilter = $this->passwordFilterAnnotation->getFilter(); 39 $this->assert IsA($passwordFilter, 'stubPasswordFilter');40 $this->assert IsA($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()); 42 44 $this->assertNull($passwordFilter->getEncoder()); 43 45 } … … 45 47 /** 46 48 * test that the correct filter is created 49 * 50 * @test 47 51 */ 48 public function testWithValidators()52 public function withValidators() 49 53 { 50 54 $this->passwordFilterAnnotation->setMinLength(8); 51 55 $passwordFilter = $this->passwordFilterAnnotation->getFilter(); 52 $this->assert IsA($passwordFilter, 'stubPasswordFilter');53 $this->assert IsA($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()); 55 59 $this->assertNull($passwordFilter->getEncoder()); 56 60 } … … 58 62 /** 59 63 * assert that the encoder is set correct 64 * 65 * @test 60 66 */ 61 public function testWithEncoder()67 public function withEncoder() 62 68 { 63 69 $this->passwordFilterAnnotation->setEncoder(new stubReflectionClass('net::stubbles::php::string::stubMd5Encoder')); 64 70 $passwordFilter = $this->passwordFilterAnnotation->getFilter(); 65 $this->assert IsA($passwordFilter, 'stubPasswordFilter');66 $this->assert IsA($passwordFilter->getEncoder(), 'stubMd5Encoder');71 $this->assertType('stubPasswordFilter', $passwordFilter); 72 $this->assertType('stubMd5Encoder', $passwordFilter->getEncoder()); 67 73 } 68 74 } trunk/src/test/php/net/stubbles/ipo/request/broker/annotations/stubStringFilterAnnotationTestCase.php
r1223 r1282 14 14 * @subpackage ipo_request_broker_annotations_test 15 15 */ 16 class stubStringFilterAnnotationTestCase extends UnitTestCase16 class stubStringFilterAnnotationTestCase extends PHPUnit_Framework_TestCase 17 17 { 18 18 /** … … 33 33 /** 34 34 * test that the correct filter is created 35 * 36 * @test 35 37 */ 36 public function testInstance()38 public function instance() 37 39 { 38 40 $stringFilter = $this->stringFilterAnnotation->getFilter(); 39 $this->assert IsA($stringFilter, 'stubStringFilter');41 $this->assertType('stubStringFilter', $stringFilter); 40 42 $this->assertNull($stringFilter->getMinLengthValidator()); 41 43 $this->assertNull($stringFilter->getMaxLengthValidator()); 42 $this->assert IsA($stringFilter->getRegexValidator(), 'stubRegexValidator');43 $this->assertEqual ($stringFilter->getRegexValidator()->getValue(), '');44 $this->assertType('stubRegexValidator', $stringFilter->getRegexValidator()); 45 $this->assertEquals('', $stringFilter->getRegexValidator()->getValue()); 44 46 } 45 47 46 48 /** 47 49 * test that the correct filter is created 50 * 51 * @test 48 52 */ 49 public function testWithValidators()53 public function withValidators() 50 54 { 51 55 $this->stringFilterAnnotation->setMinLength(1); … … 53 57 $this->stringFilterAnnotation->setRegex('/foo/'); 54 58 $stringFilter = $this->stringFilterAnnotation->getFilter(); 55 $this->assert IsA($stringFilter, 'stubStringFilter');56 $this->assert IsA($stringFilter->getMinLengthValidator(), 'stubMinLengthValidator');57 $this->assert IsA($stringFilter->getMaxLengthValidator(), 'stubMaxLengthValidator');58 $this->assertEqual ($stringFilter->getMinLengthValidator()->getValue(), 1);59 $this->assertEqual ($stringFilter->getMaxLengthValidator()->getValue(), 2);60 $this->assert IsA($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()); 62 66 } 63 67 64 68 /** 65 69 * assert that the encoder is set correct 70 * 71 * @test 66 72 */ 67 public function testWithEncoder()73 public function withEncoder() 68 74 { 69 75 $this->stringFilterAnnotation->setEncoder(new stubReflectionClass('net::stubbles::php::string::stubMd5Encoder')); 70 76 $stringFilter = $this->stringFilterAnnotation->getFilter(); 71 $this->assert IsA($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()); 73 79 $this->stringFilterAnnotation->setEncoderMode(stubStringEncoder::MODE_ENCODE); 74 80 $stringFilter = $this->stringFilterAnnotation->getFilter(); 75 $this->assert IsA($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()); 77 83 } 78 84 79 85 /** 80 86 * test that finish() works as expected 87 * 88 * @test 89 * @expectedException ReflectionException 81 90 */ 82 public function testFinishWithoutRegex()91 public function finishWithoutRegex() 83 92 { 84 $this->stringFilterAnnotation->setRegex(); 85 $this->expectException('ReflectionException'); 93 $this->stringFilterAnnotation->setRegex(''); 86 94 $this->stringFilterAnnotation->finish(); 87 95 } … … 89 97 /** 90 98 * test that finish() works as expected 99 * 100 * @test 101 * @expectedException ReflectionException 91 102 */ 92 public function testFinishWithWrongEncoderMode()103 public function finishWithWrongEncoderMode() 93 104 { 105 $this->stringFilterAnnotation->setMinLength(1); 106 $this->stringFilterAnnotation->setMaxLength(2); 107 $this->stringFilterAnnotation->setRegex('/foo/'); 94 108 $this->stringFilterAnnotation->setEncoder(new stubReflectionClass('net::stubbles::php::string::stubMd5Encoder')); 95 109 $this->stringFilterAnnotation->setEncoderMode('invalid'); 96 $this->expectException('ReflectionException');97 110 $this->stringFilterAnnotation->finish(); 98 111 } trunk/src/test/php/net/stubbles/ipo/request/broker/annotations/stubTextFilterAnnotationTestCase.php
r1223 r1282 14 14 * @subpackage ipo_request_broker_annotations_test 15 15 */ 16 class stubTextFilterAnnotationTestCase extends UnitTestCase16 class stubTextFilterAnnotationTestCase extends PHPUnit_Framework_TestCase 17 17 { 18 18 /** … … 33 33 /** 34 34 * test that the correct filter is created 35 * 36 * @test 35 37 */ 36 public function testInstance()38 public function instance() 37 39 { 38 40 $textFilter = $this->textFilterAnnotation->getFilter(); 39 $this->assert IsA($textFilter, 'stubTextFilter');41 $this->assertType('stubTextFilter', $textFilter); 40 42 $this->assertNull($textFilter->getMinLengthValidator()); 41 43 $this->assertNull($textFilter->getMaxLengthValidator()); 42 $this->assertEqual ($textFilter->getAllowedTags(), array());44 $this->assertEquals(array(), $textFilter->getAllowedTags()); 43 45 } 44 46 45 47 /** 46 48 * test that the correct filter is created 49 * 50 * @test 47 51 */ 48 public function testWithValidators()52 public function withValidators() 49 53 { 50 54 $this->textFilterAnnotation->setMinLength(1); … … 52 56 $this->textFilterAnnotation->setAllowedTags('foo, bar, baz'); 53 57 $textFilter = $this->textFilterAnnotation->getFilter(); 54 $this->assert IsA($textFilter, 'stubTextFilter');55 $this->assert IsA($textFilter->getMinLengthValidator(), 'stubMinLengthValidator');56 $this->assert IsA($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()); 60 64 } 61 65 62 66 /** 63 67 * assert that the encoder is set correct 68 * 69 * @test 64 70 */ 65 public function testWithEncoder()71 public function withEncoder() 66 72 { 67 73 $this->textFilterAnnotation->setEncoder(new stubReflectionClass('net::stubbles::php::string::stubMd5Encoder')); 68 74 $textFilter = $this->textFilterAnnotation->getFilter(); 69 $this->assert IsA($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()); 71 77 $this->textFilterAnnotation->setEncoderMode(stubStringEncoder::MODE_ENCODE); 72 78 $textFilter = $this->textFilterAnnotation->getFilter(); 73 $this->assert IsA($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()); 75 81 } 76 82 77 83 /** 78 84 * test that finish() works as expected 85 * 86 * @test 87 * @expectedException ReflectionException 79 88 */ 80 public function testFinishWithWrongEncoderMode()89 public function finishWithWrongEncoderMode() 81 90 { 82 91 $this->textFilterAnnotation->setEncoder(new stubReflectionClass('net::stubbles::php::string::stubMd5Encoder')); 83 92 $this->textFilterAnnotation->setEncoderMode('invalid'); 84 $this->expectException('ReflectionException');85 93 $this->textFilterAnnotation->finish(); 86 94 } trunk/src/test/php/net/stubbles/ipo/request/broker/stubRequestBrokerTestCase.php
r1241 r1282 8 8 */ 9 9 stubClassLoader::load('net::stubbles::ipo::request::broker::stubRequestBroker'); 10 Mock::generate('stubRequest');11 10 require_once dirname(__FILE__) . '/TestBrokerClasses.php'; 12 11 /** … … 16 15 * @subpackage ipo_request_broker_test 17 16 */ 18 class stubRequestBrokerTestCase extends UnitTestCase17 class stubRequestBrokerTestCase extends PHPUnit_Framework_TestCase 19 18 { 20 19 /** … … 27 26 * mocked request instance 28 27 * 29 * @var SimpleMock28 * @var PHPUnit_Framework_MockObject_MockObject 30 29 */ 31 30 protected $mockRequest; … … 37 36 { 38 37 $this->requestBroker = new stubRequestBroker(); 39 $this->mockRequest = new MockstubRequest();38 $this->mockRequest = $this->getMock('stubRequest'); 40 39 } 41 40 42 41 /** 43 42 * test that an illegal object throws an stubIllegalArgumentException 43 * 44 * @test 45 * @expectedException stubIllegalArgumentException 44 46 */ 45 public function testIllegalObject()47 public function illegalObject() 46 48 { 47 $this->expectException('stubIllegalArgumentException');48 49 $this->requestBroker->process($this->mockRequest, 'foo'); 49 50 } … … 51 52 /** 52 53 * test broking with a class that is not an instance of net::stubbles::lang::stubObject 54 * 55 * @test 53 56 */ 54 public function testWithClassThatIsNotInstanceOfStubObject()57 public function withClassThatIsNotInstanceOfStubObject() 55 58 { 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)); 63 65 $testClass = new TestBrokerClass(); 64 66 $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()); 67 69 $this->assertNull($testClass->getBaz()); 68 70 $this->assertNull(TestBrokerClass::$dummy); … … 71 73 /** 72 74 * test broking with a class that is an instance of net::stubbles::lang::stubObject 75 * 76 * @test 73 77 */ 74 public function testWithClassThatIsInstanceOfStubObject()78 public function withClassThatIsInstanceOfStubObject() 75 79 { 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)); 83 86 $testClass = new TestBrokerObject(); 84 87 $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()); 87 90 $this->assertNull($testClass->getBaz()); 88 91 $this->assertNull(TestBrokerObject::$dummy);
