Changeset 1171
- Timestamp:
- 12/20/07 16:56:37 (1 year ago)
- Files:
-
- trunk/src/main/php/net/stubbles/ipo/request/filters/stubRegexFilterDecorator.php (modified) (1 diff)
- trunk/src/main/php/net/stubbles/ipo/request/filters/stubStringFilter.php (modified) (3 diffs)
- trunk/src/test/php/net/stubbles/ipo/request/filters/stubRegexFilterDecoratorTestCase.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/main/php/net/stubbles/ipo/request/filters/stubRegexFilterDecorator.php
r1166 r1171 77 77 public function execute($value) 78 78 { 79 if ($value != null) { 79 if ($value != null) { 80 80 switch ($this->strategy) { 81 81 case self::STRATEGY_BEFORE: 82 $ checked= @preg_match($this->regex, $value, $matches);83 if ($ checked== false) {82 $matchAmount = @preg_match($this->regex, $value, $matches); 83 if ($matchAmount === false) { 84 84 throw new stubRuntimeException('Invalid regular expression ' . $this->regex); 85 } else { 86 $result = ($matchAmount !== 0)? $this->getDecoratedFilter()->execute($matches[0]): null; 85 87 } 86 $result = $this->getDecoratedFilter()->execute($matches[0]);87 88 break; 88 89 89 90 case self::STRATEGY_AFTER: 90 91 $filtered = $this->getDecoratedFilter()->execute($value); 91 $ checked= @preg_match($this->regex, $filtered, $matches);92 if ($ checked== false) {92 $matchAmount = @preg_match($this->regex, $filtered, $matches); 93 if ($matchAmount === false) { 93 94 throw new stubRuntimeException('Invalid regular expression ' . $this->regex); 95 } else { 96 $result = $matches[0]; 94 97 } 95 $result = $matches[0];96 98 break; 97 99 trunk/src/main/php/net/stubbles/ipo/request/filters/stubStringFilter.php
r1166 r1171 7 7 * @subpackage ipo_request_filters 8 8 */ 9 stubClassLoader::load('net.stubbles.ipo.request.filters.stubAbstractStringFilter'); 10 stubClassLoader::load('net.stubbles.ipo.request.filters.stubSimpleStringFilter'); 9 stubClassLoader::load('net.stubbles.ipo.request.filters.stubAbstractStringFilter', 10 'net.stubbles.ipo.request.filters.stubSimpleStringFilter' 11 ); 11 12 /** 12 13 * Class for filtering strings (singe line). … … 19 20 * @uses net.stubbles.util.validators 20 21 */ 21 class stubStringFilter extends stub AbstractStringFilter22 class stubStringFilter extends stubSimpleStringFilter 22 23 { 23 24 /** … … 60 61 { 61 62 if (null != $value) { 62 $simpleStringFilter = new stubSimpleStringFilter($this->rveFactory); 63 $value = $simpleStringFilter->execute($value); 63 $value = parent::doExecute($value); 64 64 65 65 if ($this->regex->validate($value) == false) { trunk/src/test/php/net/stubbles/ipo/request/filters/stubRegexFilterDecoratorTestCase.php
r1166 r1171 82 82 83 83 /** 84 * assure regex functionality (with valid & invalid) regex and filtering of values 84 * assure regex functionality and filtering of values 85 * - with matching & nonmatching values 86 * - with valid & invalid regex 85 87 */ 86 88 public function testBeforeDecoratorRegex() … … 89 91 $this->assertEqual('start_middle', $result); 90 92 93 $result = $this->beforeDecorator->execute('start_middle'); 94 $this->assertNull($result); 95 91 96 $this->expectException('stubRuntimeException'); 92 $result = $this->beforeDecorator->execute('start_middle'); 97 $invalidRegexDecorator = new stubRegexFilterDecorator($this->ssFilter, 'noRegexSlashes', stubRegexFilterDecorator::STRATEGY_BEFORE); 98 $invalidRegexDecorator->execute('irrelevant for this test'); 93 99 } 94 100 95 101 /** 96 * assure regex functionality (with valid & invalid) and filtering of values 102 * assure regex functionality and filtering of values 103 * - with matching & nonmatching values 104 * - with valid & invalid regex 97 105 */ 98 106 public function testAfterDecoratorRegex() … … 100 108 $result = $this->afterDecorator->execute('start_middle_end'); 101 109 $this->assertEqual('start_middle', $result); 110 111 $result = $this->afterDecorator->execute('start_middle'); 112 $this->assertNull($result); 102 113 103 114 $this->expectException('stubRuntimeException'); 104 $result = $this->afterDecorator->execute('start_middle'); 115 $invalidRegexDecorator = new stubRegexFilterDecorator($this->ssFilter, 'noRegexSlashes', stubRegexFilterDecorator::STRATEGY_AFTER); 116 $invalidRegexDecorator->execute('irrelevant for this test'); 105 117 } 106 118 … … 112 124 $invalidStrategyDecorator = new stubRegexFilterDecorator($this->ssFilter, $this->regex, -23); 113 125 $this->expectException('stubIllegalArgumentException'); 114 $invalidStrategyDecorator->execute(' not important');115 $invalidStrategyDecorator->execute(' not important');126 $invalidStrategyDecorator->execute('irrelevant for this test'); 127 $invalidStrategyDecorator->execute('irrelevant for this test'); 116 128 } 117 129 }
