public function getMangler() { if (!isset($this->mangler)) { $this->mangler = StringMatcher::emptyMatcher(); } return $this->mangler; }
/** * @dataProvider problematicMessageKeyProvider */ public function testKeyMangling($key, $comment) { $matcher = StringMatcher::emptyMatcher(); $mangled = $matcher->mangle($key); $title = Title::makeTitleSafe(NS_MEDIAWIKI, $mangled); $this->assertInstanceOf('Title', $title, "Key '{$mangled}' did not produce a valid title"); $unmangled = $matcher->unMangle($mangled); $this->assertEquals($key, $unmangled, 'Mangling is reversible'); }
public function testGenerateMessageBlock() { $ffs = MessageGroupBase::factory($this->conf)->getFFS(); $obj = new ReflectionObject($ffs); $method = $obj->getMethod('generateMessageBlock'); $method->setAccessible(true); $collection = new MockMessageCollectionForExport(); $mangler = StringMatcher::emptyMatcher(); $result = $method->invoke($ffs, $collection, $mangler); $expected = "\n\t'translatedmsg' => 'translation',\n\t'fuzzymsg' => 'translation', # Fuzzy\n"; $this->assertEquals($expected, $result); }
public function getMangler() { if (!isset($this->mangler)) { $class = $this->getFromConf('MANGLER', 'class'); if ($class === null) { $this->mangler = StringMatcher::emptyMatcher(); return $this->mangler; } if (!class_exists($class)) { throw new MWException("Mangler class {$class} does not exist."); } /** * @todo Branch handling, merge with upper branch keys */ $this->mangler = new $class(); $this->mangler->setConf($this->conf['MANGLER']); } return $this->mangler; }
public function __construct() { $this->mangler = StringMatcher::emptyMatcher(); }