/** * @testdox replace() creates a #regexp filter for each attribute created */ public function testCreatesAttributesWithFilter() { $tag = $this->configurator->Preg->replace('/(?<w>[0-9]+),(?<h>[0-9]+)/', ''); $regexp = '/^[0-9]+$/D'; $filter = new RegexpFilter($regexp); $callback = $filter->getCallback(); $this->assertSame($callback, $tag->attributes['w']->filterChain[0]->getCallback()); $this->assertSame($regexp, $tag->attributes['w']->filterChain[0]->getRegexp()); $this->assertSame($callback, $tag->attributes['h']->filterChain[0]->getCallback()); $this->assertSame($regexp, $tag->attributes['h']->filterChain[0]->getRegexp()); }
public function __construct(array $values = \null, $caseSensitive = \false) { parent::__construct(); if (isset($values)) { $this->setValues($values, $caseSensitive); } }
/** * @testdox asConfig() creates a JS variant for the regexp */ public function testAsConfigVariant() { $filter = new RegexpFilter(); $filter->setRegexp('/x/'); $config = $filter->asConfig(); $slice = array_slice($config['params'], 1, 1); $variant = end($slice); $this->assertInstanceOf('s9e\\TextFormatter\\Configurator\\Items\\Variant', $variant); $this->assertTrue($variant->has('JS')); $this->assertInstanceOf('s9e\\TextFormatter\\Configurator\\JavaScript\\Code', $variant->get('JS')); }