Changeset 1585
- Timestamp:
- 05/24/08 03:47:28 (3 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/main/php/net/stubbles/ipo/request/broker/annotations/stubStringFilterAnnotation.php
r1547 r1585 25 25 * @var string 26 26 */ 27 protected $regex = null; 27 protected $regex = null; 28 /** 29 * error if to be used 30 * 31 * @var string 32 */ 33 protected $errorId = null; 28 34 29 35 /** … … 38 44 39 45 /** 46 * set error id to be used in case regular expression fails 47 * 48 * @param string $errorId 49 */ 50 public function setRegexErrorId($errorId) 51 { 52 $this->errorId = $errorId; 53 } 54 55 /** 40 56 * returns the filter defined by the annotation 41 57 * … … 47 63 if (null !== $this->regex) { 48 64 $stringFilter = new stubValidatorFilterDecorator($stringFilter, $this->createRVEFactory(), new stubRegexValidator($this->regex)); 65 if (null !== $this->errorId) { 66 $stringFilter->setErrorId($this->errorId); 67 } 49 68 } 50 69 trunk/src/test/php/net/stubbles/ipo/request/broker/annotations/stubStringFilterAnnotationTestCase.php
r1324 r1585 53 53 $filter = $this->stringFilterAnnotation->getFilter(); 54 54 $this->assertType('stubValidatorFilterDecorator', $filter); 55 $this->assertEquals('FIELD_WRONG_VALUE', $filter->getErrorId()); 56 $this->assertType('stubRegexValidator', $filter->getValidator()); 57 $this->assertEquals('/foo/', $filter->getValidator()->getValue()); 58 $this->assertType('stubStringFilter', $filter->getDecoratedFilter()); 59 } 60 61 /** 62 * test that the correct filter is created 63 * 64 * @test 65 */ 66 public function withValidatorAndDifferentErrorId() 67 { 68 $this->stringFilterAnnotation->setRegex('/foo/'); 69 $this->stringFilterAnnotation->setRegexErrorId('foo'); 70 $filter = $this->stringFilterAnnotation->getFilter(); 71 $this->assertType('stubValidatorFilterDecorator', $filter); 72 $this->assertEquals('foo', $filter->getErrorId()); 55 73 $this->assertType('stubRegexValidator', $filter->getValidator()); 56 74 $this->assertEquals('/foo/', $filter->getValidator()->getValue());
