/** * {@inheritdoc} */ public function generate() { $fileName = strtolower($this->caller->getOption('filename')); $path = FakerinoConf::get('fakeFilePath') . DIRECTORY_SEPARATOR . FakerinoConf::get('locale') . DIRECTORY_SEPARATOR; if ($fakeFile = FakeTxtFile::getSource($fileName, $path)) { $lines = file($fakeFile); $index = mt_rand(0, count($lines) - 1); $element = $lines[$index]; return preg_replace("/\r|\n/", "", $element); } else { return; } }
public function testGetSource() { $container = new FakeTxtFile(); $fileDir = __DIR__ . '/../Fixtures/'; $this->assertInstanceOf('\\SplFileInfo', $container->getSource('file', $fileDir)); }