Changeset 1377
- Timestamp:
- 02/26/08 17:29:53 (6 months ago)
- Files:
-
- trunk/src/main/php/net/stubbles/ipo/request/broker/annotations/stubAbstractStringFilterAnnotation.php (modified) (5 diffs)
- trunk/src/main/php/net/stubbles/ipo/request/broker/annotations/stubFloatFilterAnnotation.php (modified) (5 diffs)
- trunk/src/main/php/net/stubbles/ipo/request/broker/annotations/stubIntegerFilterAnnotation.php (modified) (5 diffs)
- trunk/src/test/php/net/stubbles/ipo/request/broker/annotations/stubAbstractStringFilterAnnotationTestCase.php (modified) (1 diff)
- trunk/src/test/php/net/stubbles/ipo/request/broker/annotations/stubFloatFilterAnnotationTestCase.php (modified) (1 diff)
- trunk/src/test/php/net/stubbles/ipo/request/broker/annotations/stubIntegerFilterAnnotationTestCase.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/main/php/net/stubbles/ipo/request/broker/annotations/stubAbstractStringFilterAnnotation.php
r1325 r1377 30 30 protected $minLength; 31 31 /** 32 * the error id to use in case min length validation fails 33 * 34 * @var string 35 */ 36 protected $minLengthErrorId; 37 /** 32 38 * maximum length of the string 33 39 * … … 35 41 */ 36 42 protected $maxLength; 43 /** 44 * the error id to use in case max length validation fails 45 * 46 * @var string 47 */ 48 protected $maxLengthErrorId; 37 49 /** 38 50 * the encoder class to be used … … 71 83 72 84 /** 85 * sets the error id to use in case min length validation fails 86 * 87 * @param string $minLengthErrorId 88 */ 89 public function setMinLengthErrorId($minLengthErrorId) 90 { 91 $this->minLengthErrorId = $minLengthErrorId; 92 } 93 94 /** 73 95 * sets the maximum length of the string 74 96 * … … 78 100 { 79 101 $this->maxLength = $maxLength; 102 } 103 104 /** 105 * sets the error id to use in case max length validation fails 106 * 107 * @param string $maxLengthErrorId 108 */ 109 public function setMaxLengthErrorId($maxLengthErrorId) 110 { 111 $this->maxLengthErrorId = $maxLengthErrorId; 80 112 } 81 113 … … 111 143 $filter = new stubLengthFilterDecorator($filter, $this->createRVEFactory()); 112 144 if (null !== $this->minLength) { 113 $filter->setMinLengthValidator(new stubMinLengthValidator($this->minLength) );145 $filter->setMinLengthValidator(new stubMinLengthValidator($this->minLength), $this->minLengthErrorId); 114 146 } 115 147 116 148 if (null !== $this->maxLength) { 117 $filter->setMaxLengthValidator(new stubMaxLengthValidator($this->maxLength) );149 $filter->setMaxLengthValidator(new stubMaxLengthValidator($this->maxLength), $this->maxLengthErrorId); 118 150 } 119 151 } trunk/src/main/php/net/stubbles/ipo/request/broker/annotations/stubFloatFilterAnnotation.php
r1329 r1377 29 29 protected $minValue; 30 30 /** 31 * the error id to use in case min validation fails 32 * 33 * @var string 34 */ 35 protected $minErrorId; 36 /** 31 37 * maximum value of the float 32 38 * … … 34 40 */ 35 41 protected $maxValue; 42 /** 43 * the error id to use in case max validation fails 44 * 45 * @var string 46 */ 47 protected $maxErrorId; 36 48 37 49 /** … … 43 55 { 44 56 $this->minValue = $minValue; 57 } 58 59 /** 60 * sets the error id to use in case max validation fails 61 * 62 * @param string $minErrorId 63 */ 64 public function setMinErrorId($minErrorId) 65 { 66 $this->minErrorId = $minErrorId; 45 67 } 46 68 … … 56 78 57 79 /** 80 * sets the error id to use in case max validation fails 81 * 82 * @param string $maxErrorId 83 */ 84 public function setMaxErrorId($maxErrorId) 85 { 86 $this->maxErrorId = $maxErrorId; 87 } 88 89 /** 58 90 * returns the filter defined by the annotation 59 91 * … … 66 98 $filter = new stubRangeFilterDecorator($filter, $this->createRVEFactory()); 67 99 if (null !== $this->minValue) { 68 $filter->setMinValidator(new stubMinNumberValidator($this->minValue) );100 $filter->setMinValidator(new stubMinNumberValidator($this->minValue), $this->minErrorId); 69 101 } 70 102 71 103 if (null !== $this->maxValue) { 72 $filter->setMaxValidator(new stubMaxNumberValidator($this->maxValue) );104 $filter->setMaxValidator(new stubMaxNumberValidator($this->maxValue), $this->maxErrorId); 73 105 } 74 106 } trunk/src/main/php/net/stubbles/ipo/request/broker/annotations/stubIntegerFilterAnnotation.php
r1329 r1377 29 29 protected $minValue; 30 30 /** 31 * the error id to use in case min validation fails 32 * 33 * @var string 34 */ 35 protected $minErrorId; 36 /** 31 37 * maximum value of the integer 32 38 * … … 34 40 */ 35 41 protected $maxValue; 42 /** 43 * the error id to use in case max validation fails 44 * 45 * @var string 46 */ 47 protected $maxErrorId; 36 48 37 49 /** … … 43 55 { 44 56 $this->minValue = $minValue; 57 } 58 59 /** 60 * sets the error id to use in case max validation fails 61 * 62 * @param string $minErrorId 63 */ 64 public function setMinErrorId($minErrorId) 65 { 66 $this->minErrorId = $minErrorId; 45 67 } 46 68 … … 56 78 57 79 /** 80 * sets the error id to use in case max validation fails 81 * 82 * @param string $maxErrorId 83 */ 84 public function setMaxErrorId($maxErrorId) 85 { 86 $this->maxErrorId = $maxErrorId; 87 } 88 89 /** 58 90 * returns the filter defined by the annotation 59 91 * … … 66 98 $filter = new stubRangeFilterDecorator($filter, $this->createRVEFactory()); 67 99 if (null !== $this->minValue) { 68 $filter->setMinValidator(new stubMinNumberValidator($this->minValue) );100 $filter->setMinValidator(new stubMinNumberValidator($this->minValue), $this->minErrorId); 69 101 } 70 102 71 103 if (null !== $this->maxValue) { 72 $filter->setMaxValidator(new stubMaxNumberValidator($this->maxValue) );104 $filter->setMaxValidator(new stubMaxNumberValidator($this->maxValue), $this->maxErrorId); 73 105 } 74 106 } trunk/src/test/php/net/stubbles/ipo/request/broker/annotations/stubAbstractStringFilterAnnotationTestCase.php
r1323 r1377 69 69 $this->assertType('stubMaxLengthValidator', $filter->getMaxLengthValidator()); 70 70 $this->assertEquals(1, $filter->getMinLengthValidator()->getValue()); 71 $this->assertEquals('STRING_TOO_SHORT', $filter->getMinLengthErrorId()); 71 72 $this->assertEquals(2, $filter->getMaxLengthValidator()->getValue()); 73 $this->assertEquals('STRING_TOO_LONG', $filter->getMaxLengthErrorId()); 74 $this->assertSame($this->mockFilter, $filter->getDecoratedFilter()); 75 $this->abstractStringFilterAnnotation->finish(); 76 } 77 78 /** 79 * test that the correct filter is created 80 * 81 * @test 82 */ 83 public function withValidatorsAndDifferentErrorIds() 84 { 85 $this->abstractStringFilterAnnotation->setMinLength(1); 86 $this->abstractStringFilterAnnotation->setMinLengthErrorId('differentMin'); 87 $this->abstractStringFilterAnnotation->setMaxLength(2); 88 $this->abstractStringFilterAnnotation->setMaxLengthErrorId('differentMax'); 89 $filter = $this->abstractStringFilterAnnotation->getFilter(); 90 $this->assertType('stubLengthFilterDecorator', $filter); 91 $this->assertType('stubMinLengthValidator', $filter->getMinLengthValidator()); 92 $this->assertType('stubMaxLengthValidator', $filter->getMaxLengthValidator()); 93 $this->assertEquals(1, $filter->getMinLengthValidator()->getValue()); 94 $this->assertEquals('differentMin', $filter->getMinLengthErrorId()); 95 $this->assertEquals(2, $filter->getMaxLengthValidator()->getValue()); 96 $this->assertEquals('differentMax', $filter->getMaxLengthErrorId()); 72 97 $this->assertSame($this->mockFilter, $filter->getDecoratedFilter()); 73 98 $this->abstractStringFilterAnnotation->finish(); trunk/src/test/php/net/stubbles/ipo/request/broker/annotations/stubFloatFilterAnnotationTestCase.php
r1329 r1377 88 88 $this->assertType('stubMaxNumberValidator', $filter->getMaxValidator()); 89 89 $this->assertEquals(1, $filter->getMinValidator()->getValue()); 90 $this->assertEquals('VALUE_TOO_SMALL', $filter->getMinErrorId()); 90 91 $this->assertEquals(2, $filter->getMaxValidator()->getValue()); 92 $this->assertEquals('VALUE_TOO_GREAT', $filter->getMaxErrorId()); 93 $this->assertType('stubFloatFilter', $filter->getDecoratedFilter()); 94 } 95 96 /** 97 * test that the correct filter is created 98 * 99 * @test 100 */ 101 public function withBothValidatorsDifferentErrorIds() 102 { 103 $this->floatFilterAnnotation->setMinValue(1); 104 $this->floatFilterAnnotation->setMinErrorId('differentMin'); 105 $this->floatFilterAnnotation->setMaxValue(2); 106 $this->floatFilterAnnotation->setMaxErrorId('differentMax'); 107 $filter = $this->floatFilterAnnotation->getFilter(); 108 $this->assertType('stubRangeFilterDecorator', $filter); 109 $this->assertType('stubMinNumberValidator', $filter->getMinValidator()); 110 $this->assertType('stubMaxNumberValidator', $filter->getMaxValidator()); 111 $this->assertEquals(1, $filter->getMinValidator()->getValue()); 112 $this->assertEquals('differentMin', $filter->getMinErrorId()); 113 $this->assertEquals(2, $filter->getMaxValidator()->getValue()); 114 $this->assertEquals('differentMax', $filter->getMaxErrorId()); 91 115 $this->assertType('stubFloatFilter', $filter->getDecoratedFilter()); 92 116 } trunk/src/test/php/net/stubbles/ipo/request/broker/annotations/stubIntegerFilterAnnotationTestCase.php
r1329 r1377 88 88 $this->assertType('stubMaxNumberValidator', $filter->getMaxValidator()); 89 89 $this->assertEquals(1, $filter->getMinValidator()->getValue()); 90 $this->assertEquals('VALUE_TOO_SMALL', $filter->getMinErrorId()); 90 91 $this->assertEquals(2, $filter->getMaxValidator()->getValue()); 92 $this->assertEquals('VALUE_TOO_GREAT', $filter->getMaxErrorId()); 93 $this->assertType('stubIntegerFilter', $filter->getDecoratedFilter()); 94 } 95 96 /** 97 * test that the correct filter is created 98 * 99 * @test 100 */ 101 public function withBothValidatorsDifferentErrorIds() 102 { 103 $this->integerFilterAnnotation->setMinValue(1); 104 $this->integerFilterAnnotation->setMinErrorId('differentMin'); 105 $this->integerFilterAnnotation->setMaxValue(2); 106 $this->integerFilterAnnotation->setMaxErrorId('differentMax'); 107 $filter = $this->integerFilterAnnotation->getFilter(); 108 $this->assertType('stubRangeFilterDecorator', $filter); 109 $this->assertType('stubMinNumberValidator', $filter->getMinValidator()); 110 $this->assertType('stubMaxNumberValidator', $filter->getMaxValidator()); 111 $this->assertEquals(1, $filter->getMinValidator()->getValue()); 112 $this->assertEquals('differentMin', $filter->getMinErrorId()); 113 $this->assertEquals(2, $filter->getMaxValidator()->getValue()); 114 $this->assertEquals('differentMax', $filter->getMaxErrorId()); 91 115 $this->assertType('stubIntegerFilter', $filter->getDecoratedFilter()); 92 116 }
