public function testPassingPatternWithExecModifierRaisesException() { $filter = new PregReplaceFilter(); $this->setExpectedException('Zend\\Filter\\Exception\\InvalidArgumentException', '"e" pattern modifier'); $filter->setPattern('/foo/e'); }
public function testReplacementAccessorsWork() { $replacement = 'foo/bar'; $this->filter->setReplacement($replacement); $this->assertEquals($replacement, $this->filter->getReplacement()); }
/** * Do the real work, replaces the seperator to search for with the replacement seperator * * Returns the replaced string * * @param string $value * @return string * @throws Exception\RuntimeException */ protected function _separatorToSeparatorFilter($value) { if ($this->searchSeparator == null) { throw new Exception\RuntimeException('You must provide a search separator for this filter to work.'); } $this->setPattern('#' . preg_quote($this->searchSeparator, '#') . '#'); $this->setReplacement($this->replacementSeparator); return parent::filter($value); }
public function testPassingReplacementToConstructorSetsReplacement() { $replace = 'foo/bar'; $filter = new PregReplaceFilter(null, $replace); $this->assertEquals($replace, $filter->getReplacement()); }