/** * {@inheritdoc} */ public final function handle(FakeElement $data) { self::$fakeElement = $data->getName() . serialize($data->getOptions()); if (array_key_exists(self::$fakeElement, self::$outputContainer)) { return $this->getOutput(self::$outputContainer[self::$fakeElement][0], self::$outputContainer[self::$fakeElement][1]); } $processed = $this->process($data); if ($processed === null) { if ($this->successor !== null) { $processed = $this->successor->handle($data); } } return $processed; }
public function testHandler() { $handler = new FileFakerClass(); $customClass = new FakeElement('Surname'); $fakeFile = FakerinoConf::get('fakeFilePath') . DIRECTORY_SEPARATOR . FakerinoConf::get('locale') . DIRECTORY_SEPARATOR . strtolower($customClass->getName()) . '.txt'; $fileContentRaw = file($fakeFile); $fileContent = array(); foreach ($fileContentRaw as $val) { $fileContent[] = $this->cleanExtraChar($val); } $result = $handler->handle($customClass); $valueExists = in_array($result, $fileContent); $this->assertInstanceOf('Fakerino\\Core\\FakeHandler\\Handler', $handler); $this->assertInternalType('string', $result); $this->assertTrue($valueExists); }