public function run(Browscap $browscap, $inputFile, $mode)
{
$this->logger->debug('initialize Browscap');
$this->browscap = $browscap;
$fileContents = file_get_contents($inputFile);
if (false !== strpos("\r\n", $fileContents)) {
$uas = explode("\r\n", $fileContents);
} else {
$uas = explode("\n", $fileContents);
}
$foundMode = 0;
$foundInvisible = 0;
$foundUnexpected = 0;
foreach (array_unique($uas) as $ua) {
if (!$ua) {
continue;
}
$check = $this->testUA($ua, $mode);
if ($check === $mode) {
++$foundMode;
} elseif ($check === GrepCommand::FOUND_INVISIBLE) {
++$foundInvisible;
} else {
++$foundUnexpected;
}
}
$this->logger->info('Found ' . $foundMode . ' ' . $mode . ' UAs and ' . $foundInvisible . ' other UAs, ' . $foundUnexpected . ' UAs had unexpected results');
}
/** * tests running the generation of a grep command * * @group generator * @group sourcetest */ public function testRun() { $mockLogger = $this->getMock('\\Monolog\\Logger', array(), array(), '', false); self::assertSame($this->object, $this->object->setLogger($mockLogger)); $mockBrowscap = $this->getMock('\\phpbrowscap\\Browscap', array(), array(), '', false); $tmpfile = tempnam(sys_get_temp_dir(), 'browscaptest'); $in = <<<HERE ; comment test HERE; file_put_contents($tmpfile, $in); self::assertNull($this->object->run($mockBrowscap, $tmpfile, GrepCommand::MODE_UNMATCHED)); unlink($tmpfile); }