Changeset 1582
- Timestamp:
- 05/24/08 00:24:25 (5 months ago)
- Files:
-
- trunk/src/main/php/net/stubbles/ipo/request/filter/stubLengthFilterDecorator.php (modified) (1 diff)
- trunk/src/main/php/net/stubbles/ipo/request/filter/stubValidatorFilterDecorator.php (modified) (1 diff)
- trunk/src/test/php/net/stubbles/ipo/request/filter/stubLengthFilterDecoratorTestCase.php (modified) (1 diff)
- trunk/src/test/php/net/stubbles/ipo/request/filter/stubValidatorFilterDecoratorTestCase.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/main/php/net/stubbles/ipo/request/filter/stubLengthFilterDecorator.php
r1547 r1582 143 143 protected function doExecute($value) 144 144 { 145 if (strlen($value) === 0) { 146 return null; 147 } 148 145 149 if (null != $this->minLength && $this->minLength->validate($value) === false) { 146 150 // input is shorter than maximal allowed length trunk/src/main/php/net/stubbles/ipo/request/filter/stubValidatorFilterDecorator.php
r1575 r1582 85 85 protected function doExecute($value) 86 86 { 87 if ($this->validator->validate($value) == false) { 87 if (strlen($value) === 0) { 88 return null; 89 } 90 91 if ($this->validator->validate($value) === false) { 88 92 throw new stubFilterException($this->rveFactory->create($this->errorId)); 89 93 } trunk/src/test/php/net/stubbles/ipo/request/filter/stubLengthFilterDecoratorTestCase.php
r1546 r1582 70 70 71 71 /** 72 * test handling of empty values 73 * 74 * @test 75 */ 76 public function emptyValues() 77 { 78 $mockMinLengthValidaror = $this->getMock('stubValidator'); 79 $mockMinLengthValidaror->expects($this->never()) 80 ->method('validate'); 81 $this->lengthFilterDecorator->setMinLengthValidator($mockMinLengthValidaror); 82 $mockMaxLengthValidaror = $this->getMock('stubValidator'); 83 $mockMaxLengthValidaror->expects($this->never()) 84 ->method('validate'); 85 $this->lengthFilterDecorator->setMaxLengthValidator($mockMaxLengthValidaror); 86 $this->assertNull($this->lengthFilterDecorator->callDoExecute(null)); 87 $this->assertNull($this->lengthFilterDecorator->callDoExecute('')); 88 } 89 90 /** 91 * test handling of non-empty values 92 * 93 * @test 94 */ 95 public function nonEmptyValues() 96 { 97 $mockMinLengthValidaror = $this->getMock('stubValidator'); 98 $mockMinLengthValidaror->expects($this->exactly(2)) 99 ->method('validate') 100 ->will($this->returnValue(true)); 101 $this->lengthFilterDecorator->setMinLengthValidator($mockMinLengthValidaror); 102 $mockMaxLengthValidaror = $this->getMock('stubValidator'); 103 $mockMaxLengthValidaror->expects($this->exactly(2)) 104 ->method('validate') 105 ->will($this->returnValue(true)); 106 $this->lengthFilterDecorator->setMaxLengthValidator($mockMaxLengthValidaror); 107 $this->assertEquals(0, $this->lengthFilterDecorator->callDoExecute(0)); 108 $this->assertEquals('0', $this->lengthFilterDecorator->callDoExecute('0')); 109 } 110 111 /** 72 112 * assure that filtering a string with minimum length is ok and a string 73 113 * with length shorter than minimum length throws an FilterException trunk/src/test/php/net/stubbles/ipo/request/filter/stubValidatorFilterDecoratorTestCase.php
r1546 r1582 123 123 $this->validatorFilterDecorator->callDoExecute('test_value'); 124 124 } 125 126 /** 127 * test handling of empty values 128 * 129 * @test 130 */ 131 public function emptyValues() 132 { 133 $this->mockValidator->expects($this->never()) 134 ->method('validate'); 135 $this->assertNull($this->validatorFilterDecorator->callDoExecute(null)); 136 $this->assertNull($this->validatorFilterDecorator->callDoExecute('')); 137 } 138 139 /** 140 * test handling of non-empty values 141 * 142 * @test 143 */ 144 public function nonEmptyValues() 145 { 146 $this->mockValidator->expects($this->exactly(2)) 147 ->method('validate') 148 ->will($this->returnValue(true)); 149 $this->assertEquals(0, $this->validatorFilterDecorator->callDoExecute(0)); 150 $this->assertEquals('0', $this->validatorFilterDecorator->callDoExecute('0')); 151 } 152 125 153 } 126 154 ?>
