Determine if the specified property is an property that should
be included in the "full" versions of the files only
public isLiteModeProperty ( string $propertyName ) : boolean | ||
$propertyName | string | |
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'] . ')'); } }
/** * @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); }
/** * @dataProvider litePropertiesDataProvider * * @group data * @group sourcetest */ public function testIsLiteModeProperty($propertyName, $isExtra) { $actualValue = $this->object->isLiteModeProperty($propertyName); self::assertSame($isExtra, $actualValue); }