Determine if the specified property is an "extra" property (that should
be included in the "full" versions of the files)
public isOutputProperty ( string $propertyName, Browscap\Writer\WriterInterface $writer = null ) : boolean | ||
$propertyName | string | |
$writer | Browscap\Writer\WriterInterface | |
return | boolean |
/** * @dataProvider userAgentDataProvider * @coversNothing * * @param string $userAgent * @param array $expectedProperties * @param bool $lite * * @group integration * @group useragenttest * @group lite */ public function testUserAgentsLite($userAgent, $expectedProperties, $lite = true) { if (!is_array($expectedProperties) || !count($expectedProperties)) { self::markTestSkipped('Could not run test - no properties were defined to test'); } if (!$lite) { self::markTestSkipped('Test skipped - Browser/Platform/Version not defined for Lite Mode'); } self::$browscap->iniFilename = 'lite_browscap.ini'; self::$browscap->localFile = self::$buildFolder . '/lite_php_browscap.ini'; self::$browscap->cacheFilename = 'cache-lite.php'; self::$browscap->doAutoUpdate = false; self::$browscap->silent = false; self::$browscap->updateMethod = Browscap::UPDATE_LOCAL; static $updatedLiteCache = false; if (!$updatedLiteCache) { self::$browscap->updateCache(); $updatedLiteCache = true; } $actualProps = (array) self::$browscap->getBrowser($userAgent); foreach ($expectedProperties as $propName => $propValue) { if (!self::$propertyHolder->isOutputProperty($propName)) { continue; } if (!self::$propertyHolder->isLiteModeProperty($propName)) { continue; } self::assertArrayHasKey($propName, $actualProps, 'Actual properties did not have "' . $propName . '" property'); self::assertSame($propValue, $actualProps[$propName], 'Expected actual "' . $propName . '" to be "' . $propValue . '" (was "' . $actualProps[$propName] . '"; used pattern: ' . $actualProps['browser_name_pattern'] . ')'); } }
/** * tests detecting a output property if a writer is given * * @group data * @group sourcetest */ public function testIsOutputPropertyWithWriter() { $mockWriter = $this->getMockBuilder(\Browscap\Writer\CsvWriter::class)->disableOriginalConstructor()->setMethods(['getType'])->getMock(); $mockWriter->expects(self::once())->method('getType')->will(self::returnValue('csv')); $actualValue = $this->object->isOutputProperty('PropertyName', $mockWriter); self::assertTrue($actualValue); }
/** * tests detecting a output property if a writer is given * * @group data * @group sourcetest */ public function testIsOutputPropertyWithWriter() { $mockWriter = $this->getMock('\\Browscap\\Writer\\CsvWriter', array('getType'), array(), '', false); $mockWriter->expects(self::once())->method('getType')->will(self::returnValue('csv')); $actualValue = $this->object->isOutputProperty('PropertyName', $mockWriter); self::assertTrue($actualValue); }
/** * @dataProvider userAgentDataProvider * @coversNothing * * @param string $userAgent * @param array $expectedProperties * @param bool $lite * @param bool $standard * * @throws \Exception * @throws \BrowscapPHP\Exception * * @group intergration * @group useragenttest * @group lite */ public function testUserAgentsLite($userAgent, $expectedProperties, $lite = true, $standard = true) { if (!is_array($expectedProperties) || !count($expectedProperties)) { self::markTestSkipped('Could not run test - no properties were defined to test'); } if (!$lite) { self::markTestSkipped('Test skipped - Browser/Platform/Version not defined for Lite Mode'); } static $updatedLiteCache = false; if (!$updatedLiteCache) { self::$browscap->getCache()->flush(); self::$browscap->convertFile(self::$buildFolder . '/lite_php_browscap.ini'); $updatedLiteCache = true; } $actualProps = (array) self::$browscap->getBrowser($userAgent); foreach ($expectedProperties as $propName => $propValue) { if (!self::$propertyHolder->isOutputProperty($propName)) { continue; } if (!self::$propertyHolder->isLiteModeProperty($propName)) { continue; } $propName = strtolower($propName); self::assertArrayHasKey($propName, $actualProps, 'Actual properties did not have "' . $propName . '" property'); self::assertSame($propValue, $actualProps[$propName], 'Expected actual "' . $propName . '" to be "' . $propValue . '" (was "' . $actualProps[$propName] . '"; used pattern: ' . $actualProps['browser_name_pattern'] . ')'); } }
/** * checks if a property should be in the output * * @param string $property * @param \Browscap\Writer\WriterInterface|null $writer * * @return bool */ public function isOutputProperty($property, WriterInterface $writer = null) { $propertyHolder = new PropertyHolder(); if (!$propertyHolder->isOutputProperty($property, $writer)) { return false; } return $propertyHolder->isLiteModeProperty($property); }
/** * checks if a property should be in the output * * @param string $property * @param \Browscap\Writer\WriterInterface|null $writer * * @return boolean */ public function isOutputProperty($property, WriterInterface $writer = null) { $propertyHolder = new PropertyHolder(); if (!$propertyHolder->isOutputProperty($property, $writer)) { return false; } return in_array($property, $this->fields); }
/** * checks if a property should be in the output * * @param string $property * @param \Browscap\Writer\WriterInterface|null $writer * * @return bool */ public function isOutputProperty($property, WriterInterface $writer = null) { $propertyHolder = new PropertyHolder(); return $propertyHolder->isOutputProperty($property, $writer); }