Determine if the specified property is an property that should
be included in the "full" versions of the files only
public isStandardModeProperty ( 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 * * @group integration * @group useragenttest * @group standard */ public function testUserAgentsStandard($userAgent, $expectedProperties) { if (!is_array($expectedProperties) || !count($expectedProperties)) { self::markTestSkipped('Could not run test - no properties were defined to test'); } self::$browscap->iniFilename = 'browscap.ini'; self::$browscap->localFile = self::$buildFolder . '/php_browscap.ini'; self::$browscap->cacheFilename = 'cache-standard.php'; self::$browscap->doAutoUpdate = false; self::$browscap->silent = false; self::$browscap->updateMethod = Browscap::UPDATE_LOCAL; static $updatedStandardCache = false; if (!$updatedStandardCache) { self::$browscap->updateCache(); $updatedStandardCache = true; } $actualProps = (array) self::$browscap->getBrowser($userAgent); foreach ($expectedProperties as $propName => $propValue) { if (!self::$propertyHolder->isOutputProperty($propName)) { continue; } if (!self::$propertyHolder->isStandardModeProperty($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 \phpbrowscap\Exception * @group integration * @group useragenttest * @group standard */ public function testUserAgentsStandard($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 (!$standard) { self::markTestSkipped('Test skipped - Browser/Platform/Version not defined for Standard Mode'); } static $updatedStandardCache = false; if (!$updatedStandardCache) { self::$browscap->convertFile(self::$buildFolder . '/php_browscap.ini'); $updatedStandardCache = true; } $actualProps = (array) self::$browscap->getBrowser($userAgent); foreach ($expectedProperties as $propName => $propValue) { if (!self::$propertyHolder->isOutputProperty($propName)) { continue; } if (!self::$propertyHolder->isStandardModeProperty($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; } if ($propertyHolder->isLiteModeProperty($property)) { return true; } return $propertyHolder->isStandardModeProperty($property, $writer); }
/** * tests detecting a standard mode property * * @group data * @group sourcetest */ public function testIsStandardModePropertyWithWriter() { $mockWriter = $this->getMockBuilder(\Browscap\Writer\CsvWriter::class)->disableOriginalConstructor()->setMethods(['getType'])->getMock(); $mockWriter->expects(self::once())->method('getType')->will(self::returnValue('csv')); self::assertTrue($this->object->isStandardModeProperty('PropertyName', $mockWriter)); }
/** * tests detecting a standard mode property * * @group data * @group sourcetest */ public function testIsStandardModePropertyWithWriter() { $mockWriter = $this->getMock('\\Browscap\\Writer\\CsvWriter', array('getType'), array(), '', false); $mockWriter->expects(self::once())->method('getType')->will(self::returnValue('csv')); self::assertTrue($this->object->isStandardModeProperty('PropertyName', $mockWriter)); }