code
stringlengths 31
1.39M
| docstring
stringlengths 23
16.8k
| func_name
stringlengths 1
126
| language
stringclasses 1
value | repo
stringlengths 7
63
| path
stringlengths 7
166
| url
stringlengths 50
220
| license
stringclasses 7
values |
---|---|---|---|---|---|---|---|
public function testFormatPropertyValueWithException(): void
{
$actualValue = $this->object->formatPropertyValue('Browserx', 'Device_Pointing_Method');
static::assertSame('""', $actualValue);
} | tests formatting a property value
@throws Exception | testFormatPropertyValueWithException | php | browscap/browscap | tests/BrowscapTest/Formatter/CsvFormatterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Formatter/CsvFormatterTest.php | MIT |
public function testFormatPropertyValueWithUnknownValue(): void
{
$actualValue = $this->object->formatPropertyValue('unknown', 'Browser_Type');
static::assertSame('""', $actualValue);
} | tests formatting a property value
@throws Exception | testFormatPropertyValueWithUnknownValue | php | browscap/browscap | tests/BrowscapTest/Formatter/CsvFormatterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Formatter/CsvFormatterTest.php | MIT |
protected function setUp(): void
{
$propertyHolder = $this->getMockBuilder(PropertyHolder::class)
->disableOriginalConstructor()
->onlyMethods(['isOutputProperty'])
->getMock();
$propertyHolder
->expects(static::never())
->method('isOutputProperty');
$this->object = new JsonFormatter($propertyHolder);
} | @throws MethodNameAlreadyConfiguredException
@throws MethodCannotBeConfiguredException
@throws InvalidArgumentException
@throws CannotUseOnlyMethodsException | setUp | php | browscap/browscap | tests/BrowscapTest/Formatter/JsonFormatterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Formatter/JsonFormatterTest.php | MIT |
public function testGetType(): void
{
static::assertSame(FormatterInterface::TYPE_JSON, $this->object->getType());
} | tests getter for the formatter type
@throws ExpectationFailedException | testGetType | php | browscap/browscap | tests/BrowscapTest/Formatter/JsonFormatterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Formatter/JsonFormatterTest.php | MIT |
public function testFormatPropertyName(): void
{
static::assertSame('"text"', $this->object->formatPropertyName('text'));
} | tests formatting a property name
@throws ExpectationFailedException
@throws JsonException | testFormatPropertyName | php | browscap/browscap | tests/BrowscapTest/Formatter/JsonFormatterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Formatter/JsonFormatterTest.php | MIT |
public static function propertyNameTypeDataProvider(): array
{
return [
['Comment', 'test', '"test"'],
['Browser', 'test', '"test"'],
['Platform', 'test', '"test"'],
['Platform_Description', 'test', '"test"'],
['Device_Name', 'test', '"test"'],
['Device_Maker', 'test', '"test"'],
['RenderingEngine_Name', 'test', '"test"'],
['RenderingEngine_Description', 'test', '"test"'],
['Parent', 'test', '"test"'],
['Platform_Version', 'test', '"test"'],
['RenderingEngine_Version', 'test', '"test"'],
['Version', 'test', '"test"'],
['MajorVer', 'test', '"test"'],
['MinorVer', 'test', '"test"'],
['CssVersion', 'test', '"test"'],
['AolVersion', 'test', '"test"'],
['Alpha', 'true', 'true'],
['Beta', 'false', 'false'],
['Win16', 'test', '""'],
['Win32', 'test', '""'],
['Win64', 'test', '""'],
['Frames', 'test', '""'],
['IFrames', 'test', '""'],
['Tables', 'test', '""'],
['Cookies', 'test', '""'],
['BackgroundSounds', 'test', '""'],
['JavaScript', 'test', '""'],
['VBScript', 'test', '""'],
['JavaApplets', 'test', '""'],
['ActiveXControls', 'test', '""'],
['isMobileDevice', 'test', '""'],
['isSyndicationReader', 'test', '""'],
['Crawler', 'test', '""'],
['Browser_Type', 'Browser', '"Browser"'],
['Device_Type', 'Tablet', '"Tablet"'],
['Device_Pointing_Method', 'test', '""'],
];
} | Data Provider for the test testGetPropertyType
@return array<array<string>>
@throws void | propertyNameTypeDataProvider | php | browscap/browscap | tests/BrowscapTest/Formatter/JsonFormatterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Formatter/JsonFormatterTest.php | MIT |
public function testFormatPropertyValue(string $propertyName, string $inputValue, string $expectedValue): void
{
$actualValue = $this->object->formatPropertyValue($inputValue, $propertyName);
static::assertSame($expectedValue, $actualValue, sprintf('Property %s should be %s (was %s)', $propertyName, $expectedValue, $actualValue));
} | tests formatting a property value
@throws Exception
@dataProvider propertyNameTypeDataProvider | testFormatPropertyValue | php | browscap/browscap | tests/BrowscapTest/Formatter/JsonFormatterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Formatter/JsonFormatterTest.php | MIT |
public function testFormatPropertyValueWithException(): void
{
$actualValue = $this->object->formatPropertyValue('Browserx', 'Device_Pointing_Method');
static::assertSame('""', $actualValue);
} | tests formatting a property value
@throws Exception | testFormatPropertyValueWithException | php | browscap/browscap | tests/BrowscapTest/Formatter/JsonFormatterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Formatter/JsonFormatterTest.php | MIT |
public function testFormatPropertyValueWithUnknownValue(): void
{
$actualValue = $this->object->formatPropertyValue('unknown', 'Browser_Type');
static::assertSame('""', $actualValue);
} | tests formatting a property value
@throws Exception | testFormatPropertyValueWithUnknownValue | php | browscap/browscap | tests/BrowscapTest/Formatter/JsonFormatterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Formatter/JsonFormatterTest.php | MIT |
protected function setUp(): void
{
$propertyHolder = $this->getMockBuilder(PropertyHolder::class)
->disableOriginalConstructor()
->onlyMethods(['isOutputProperty'])
->getMock();
$propertyHolder
->expects(static::never())
->method('isOutputProperty');
$this->object = new PhpFormatter($propertyHolder);
} | @throws MethodNameAlreadyConfiguredException
@throws MethodCannotBeConfiguredException
@throws InvalidArgumentException
@throws CannotUseOnlyMethodsException | setUp | php | browscap/browscap | tests/BrowscapTest/Formatter/PhpFormatterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Formatter/PhpFormatterTest.php | MIT |
public function testGetType(): void
{
static::assertSame(FormatterInterface::TYPE_PHP, $this->object->getType());
} | tests getter for the formatter type
@throws ExpectationFailedException | testGetType | php | browscap/browscap | tests/BrowscapTest/Formatter/PhpFormatterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Formatter/PhpFormatterTest.php | MIT |
public function testFormatPropertyName(): void
{
static::assertSame('text', $this->object->formatPropertyName('text'));
} | tests formatting a property name
@throws ExpectationFailedException | testFormatPropertyName | php | browscap/browscap | tests/BrowscapTest/Formatter/PhpFormatterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Formatter/PhpFormatterTest.php | MIT |
public static function propertyNameTypeDataProvider(): array
{
return [
['Comment', 'test', '"test"'],
['Browser', 'test', '"test"'],
['Platform', 'test', '"test"'],
['Platform_Description', 'test', '"test"'],
['Device_Name', 'test', '"test"'],
['Device_Maker', 'test', '"test"'],
['RenderingEngine_Name', 'test', '"test"'],
['RenderingEngine_Description', 'test', '"test"'],
['Parent', 'test', '"test"'],
['Platform_Version', 'test', 'test'],
['RenderingEngine_Version', 'test', 'test'],
['Version', 'test', 'test'],
['MajorVer', 'test', 'test'],
['MinorVer', 'test', 'test'],
['CssVersion', 'test', 'test'],
['AolVersion', 'test', 'test'],
['Alpha', 'true', '"true"'],
['Beta', 'false', '"false"'],
['Win16', 'test', ''],
['Browser_Type', 'Browser', '"Browser"'],
['Device_Type', 'Tablet', '"Tablet"'],
['Device_Pointing_Method', 'mouse', '"mouse"'],
];
} | Data Provider for the test testGetPropertyType
@return array<array<string>>
@throws void | propertyNameTypeDataProvider | php | browscap/browscap | tests/BrowscapTest/Formatter/PhpFormatterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Formatter/PhpFormatterTest.php | MIT |
public function testFormatPropertyValue(string $propertyName, string $inputValue, string $expectedValue): void
{
$actualValue = $this->object->formatPropertyValue($inputValue, $propertyName);
static::assertSame($expectedValue, $actualValue, sprintf('Property %s should be %s (was %s)', $propertyName, $expectedValue, $actualValue));
} | tests formatting a property value
@throws Exception
@dataProvider propertyNameTypeDataProvider | testFormatPropertyValue | php | browscap/browscap | tests/BrowscapTest/Formatter/PhpFormatterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Formatter/PhpFormatterTest.php | MIT |
public function testFormatPropertyValueWithException(): void
{
$actualValue = $this->object->formatPropertyValue('Browserx', 'Device_Pointing_Method');
static::assertSame('', $actualValue);
} | tests formatting a property value
@throws Exception | testFormatPropertyValueWithException | php | browscap/browscap | tests/BrowscapTest/Formatter/PhpFormatterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Formatter/PhpFormatterTest.php | MIT |
public function testFormatPropertyValueWithUnknownValue(): void
{
$actualValue = $this->object->formatPropertyValue('unknown', 'Browser_Type');
static::assertSame('"unknown"', $actualValue);
} | tests formatting a property value
@throws Exception | testFormatPropertyValueWithUnknownValue | php | browscap/browscap | tests/BrowscapTest/Formatter/PhpFormatterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Formatter/PhpFormatterTest.php | MIT |
public function testFormatPropertyValueWithSpecialChars(): void
{
$actualValue = $this->object->formatPropertyValue('1.0', 'Platform_Version');
static::assertSame('"1.0"', $actualValue);
} | tests formatting a property value
@throws Exception | testFormatPropertyValueWithSpecialChars | php | browscap/browscap | tests/BrowscapTest/Formatter/PhpFormatterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Formatter/PhpFormatterTest.php | MIT |
public function testFormatPropertyValueWithoutSpecialChars(): void
{
$actualValue = $this->object->formatPropertyValue('1', 'Platform_Version');
static::assertSame('1', $actualValue);
} | tests formatting a property value
@throws Exception | testFormatPropertyValueWithoutSpecialChars | php | browscap/browscap | tests/BrowscapTest/Formatter/PhpFormatterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Formatter/PhpFormatterTest.php | MIT |
protected function setUp(): void
{
$propertyHolder = $this->getMockBuilder(PropertyHolder::class)
->disableOriginalConstructor()
->onlyMethods(['isOutputProperty'])
->getMock();
$propertyHolder
->expects(static::never())
->method('isOutputProperty');
$this->object = new XmlFormatter($propertyHolder);
} | @throws MethodNameAlreadyConfiguredException
@throws MethodCannotBeConfiguredException
@throws InvalidArgumentException
@throws CannotUseOnlyMethodsException | setUp | php | browscap/browscap | tests/BrowscapTest/Formatter/XmlFormatterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Formatter/XmlFormatterTest.php | MIT |
public function testGetType(): void
{
static::assertSame(FormatterInterface::TYPE_XML, $this->object->getType());
} | tests getter for the formatter type
@throws ExpectationFailedException | testGetType | php | browscap/browscap | tests/BrowscapTest/Formatter/XmlFormatterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Formatter/XmlFormatterTest.php | MIT |
public function testFormatPropertyName(): void
{
static::assertSame('text', $this->object->formatPropertyName('text'));
} | tests formatting a property name
@throws ExpectationFailedException | testFormatPropertyName | php | browscap/browscap | tests/BrowscapTest/Formatter/XmlFormatterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Formatter/XmlFormatterTest.php | MIT |
public static function propertyNameTypeDataProvider(): array
{
return [
['Comment', 'test', 'test'],
['Browser', 'test', 'test'],
['Platform', 'test', 'test'],
['Platform_Description', 'test', 'test'],
['Device_Name', 'test', 'test'],
['Device_Maker', 'test', 'test'],
['RenderingEngine_Name', 'test', 'test'],
['RenderingEngine_Description', 'test', 'test'],
['Parent', 'test', 'test'],
['Platform_Version', 'test', 'test'],
['RenderingEngine_Version', 'test', 'test'],
['Version', 'test', 'test'],
['MajorVer', 'test', 'test'],
['MinorVer', 'test', 'test'],
['CssVersion', 'test', 'test'],
['AolVersion', 'test', 'test'],
['Alpha', 'true', 'true'],
['Beta', 'false', 'false'],
['Win16', 'test', ''],
['Win32', 'test', ''],
['Win64', 'test', ''],
['Frames', 'test', ''],
['IFrames', 'test', ''],
['Tables', 'test', ''],
['Cookies', 'test', ''],
['BackgroundSounds', 'test', ''],
['JavaScript', 'test', ''],
['VBScript', 'test', ''],
['JavaApplets', 'test', ''],
['ActiveXControls', 'test', ''],
['isMobileDevice', 'test', ''],
['isSyndicationReader', 'test', ''],
['Crawler', 'test', ''],
['Browser_Type', 'Browser', 'Browser'],
['Device_Type', 'Tablet', 'Tablet'],
['Device_Pointing_Method', 'test', ''],
];
} | Data Provider for the test testGetPropertyType
@return array<array<string>>
@throws void | propertyNameTypeDataProvider | php | browscap/browscap | tests/BrowscapTest/Formatter/XmlFormatterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Formatter/XmlFormatterTest.php | MIT |
public function testFormatPropertyValue(string $propertyName, string $inputValue, string $expectedValue): void
{
$actualValue = $this->object->formatPropertyValue($inputValue, $propertyName);
static::assertSame($expectedValue, $actualValue, sprintf('Property %s should be %s (was %s)', $propertyName, $expectedValue, $actualValue));
} | tests formatting a property value
@throws Exception
@dataProvider propertyNameTypeDataProvider | testFormatPropertyValue | php | browscap/browscap | tests/BrowscapTest/Formatter/XmlFormatterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Formatter/XmlFormatterTest.php | MIT |
public function testFormatPropertyValueWithException(): void
{
$actualValue = $this->object->formatPropertyValue('Browserx', 'Device_Pointing_Method');
static::assertSame('', $actualValue);
} | tests formatting a property value
@throws Exception | testFormatPropertyValueWithException | php | browscap/browscap | tests/BrowscapTest/Formatter/XmlFormatterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Formatter/XmlFormatterTest.php | MIT |
public function testFormatPropertyValueWithUnknownValue(): void
{
$actualValue = $this->object->formatPropertyValue('unknown', 'Browser_Type');
static::assertSame('', $actualValue);
} | tests formatting a property value
@throws Exception | testFormatPropertyValueWithUnknownValue | php | browscap/browscap | tests/BrowscapTest/Formatter/XmlFormatterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Formatter/XmlFormatterTest.php | MIT |
public function testConstructFailsIfTheDirDoesNotExsist(): void
{
$this->expectException(DirectoryMissingException::class);
$this->expectExceptionMessage('The directory "/dar" does not exist, or we cannot access it');
$writerCollection = $this->createMock(WriterCollection::class);
$dataCollectionFactory = $this->createMock(DataCollectionFactory::class);
assert($writerCollection instanceof WriterCollection);
assert($dataCollectionFactory instanceof DataCollectionFactory);
new BuildGenerator('/dar', '', $this->logger, $writerCollection, $dataCollectionFactory);
} | tests failing the build if the build dir does not exist
@throws InvalidArgumentException | testConstructFailsIfTheDirDoesNotExsist | php | browscap/browscap | tests/BrowscapTest/Generator/BuildGeneratorTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Generator/BuildGeneratorTest.php | MIT |
public function testConstructFailsIfTheDirIsNotAnDirectory(): void
{
$this->expectException(NotADirectoryException::class);
$this->expectExceptionMessage('The path "' . __FILE__ . '" did not resolve to a directory');
$writerCollection = $this->createMock(WriterCollection::class);
$dataCollectionFactory = $this->createMock(DataCollectionFactory::class);
assert($writerCollection instanceof WriterCollection);
assert($dataCollectionFactory instanceof DataCollectionFactory);
new BuildGenerator(__FILE__, '', $this->logger, $writerCollection, $dataCollectionFactory);
} | tests failing the build if no build dir is a file
@throws InvalidArgumentException | testConstructFailsIfTheDirIsNotAnDirectory | php | browscap/browscap | tests/BrowscapTest/Generator/BuildGeneratorTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Generator/BuildGeneratorTest.php | MIT |
public function testBuild(): void
{
$useragent = $this->getMockBuilder(UserAgent::class)
->disableOriginalConstructor()
->onlyMethods(['getUserAgent', 'getProperties'])
->getMock();
$useragent
->expects(static::exactly(2))
->method('getUserAgent')
->willReturn('abc');
$useragent
->expects(static::exactly(2))
->method('getProperties')
->willReturn([
'Parent' => 'DefaultProperties',
'Comment' => 'Default Browser',
'Browser' => 'Default Browser',
'Browser_Type' => 'unknown',
'Browser_Bits' => 0,
'Browser_Maker' => 'unknown',
'Browser_Modus' => 'unknown',
'Version' => '0.0',
'MajorVer' => '0',
'MinorVer' => '0',
'Platform' => 'unknown',
'Platform_Version' => 'unknown',
'Platform_Description' => 'unknown',
'Platform_Bits' => 0,
'Platform_Maker' => 'unknown',
'Alpha' => false,
'Beta' => false,
'Win16' => false,
'Win32' => false,
'Win64' => false,
'Frames' => false,
'IFrames' => false,
'Tables' => false,
'Cookies' => false,
'BackgroundSounds' => false,
'JavaScript' => false,
'VBScript' => false,
'JavaApplets' => false,
'ActiveXControls' => false,
'isMobileDevice' => false,
'isTablet' => false,
'isSyndicationReader' => false,
'Crawler' => false,
'isFake' => false,
'isAnonymized' => false,
'isModified' => false,
'CssVersion' => 0,
'AolVersion' => 0,
'Device_Name' => 'unknown',
'Device_Maker' => 'unknown',
'Device_Type' => 'unknown',
'Device_Pointing_Method' => 'unknown',
'Device_Code_Name' => 'unknown',
'Device_Brand_Name' => 'unknown',
'RenderingEngine_Name' => 'unknown',
'RenderingEngine_Version' => 'unknown',
'RenderingEngine_Description' => 'unknown',
'RenderingEngine_Maker' => 'unknown',
'PatternId' => 'resources/core/default-browser.json::u0',
]);
$division = $this->getMockBuilder(Division::class)
->disableOriginalConstructor()
->onlyMethods(['getUserAgents', 'getVersions'])
->getMock();
$division
->expects(static::exactly(2))
->method('getUserAgents')
->willReturn(
[0 => $useragent],
);
$division
->expects(static::once())
->method('getVersions')
->willReturn(['2']);
$defaultProperties = $this->getMockBuilder(UserAgent::class)
->disableOriginalConstructor()
->onlyMethods(['getUserAgent', 'getProperties'])
->getMock();
$defaultProperties
->expects(static::exactly(2))
->method('getUserAgent')
->willReturn('DefaultProperties');
$defaultProperties
->expects(static::exactly(3))
->method('getProperties')
->willReturn([
'Comment' => 'Defaultproperties',
'Browser' => 'Defaultproperties',
'Browser_Type' => 'unknown',
'Browser_Bits' => 0,
'Browser_Maker' => 'unknown',
'Browser_Modus' => 'unknown',
'Version' => '0.0',
'MajorVer' => '0',
'MinorVer' => '0',
'Platform' => 'unknown',
'Platform_Version' => 'unknown',
'Platform_Description' => 'unknown',
'Platform_Bits' => 0,
'Platform_Maker' => 'unknown',
'Alpha' => false,
'Beta' => false,
'Win16' => false,
'Win32' => false,
'Win64' => false,
'Frames' => false,
'IFrames' => false,
'Tables' => false,
'Cookies' => false,
'BackgroundSounds' => false,
'JavaScript' => false,
'VBScript' => false,
'JavaApplets' => false,
'ActiveXControls' => false,
'isMobileDevice' => false,
'isTablet' => false,
'isSyndicationReader' => false,
'Crawler' => false,
'isFake' => false,
'isAnonymized' => false,
'isModified' => false,
'CssVersion' => 0,
'AolVersion' => 0,
'Device_Name' => 'unknown',
'Device_Maker' => 'unknown',
'Device_Type' => 'unknown',
'Device_Pointing_Method' => 'unknown',
'Device_Code_Name' => 'unknown',
'Device_Brand_Name' => 'unknown',
'RenderingEngine_Name' => 'unknown',
'RenderingEngine_Version' => 'unknown',
'RenderingEngine_Description' => 'unknown',
'RenderingEngine_Maker' => 'unknown',
'PatternId' => 'resources/core/default-browser.json::u0',
]);
$coreDivision = $this->getMockBuilder(Division::class)
->disableOriginalConstructor()
->onlyMethods(['getUserAgents'])
->getMock();
$coreDivision
->expects(static::exactly(2))
->method('getUserAgents')
->willReturn(
[0 => $defaultProperties],
);
$collection = $this->getMockBuilder(DataCollection::class)
->disableOriginalConstructor()
->onlyMethods(['getDefaultProperties', 'getDefaultBrowser', 'getDivisions'])
->getMock();
$collection
->expects(static::exactly(2))
->method('getDefaultProperties')
->willReturn($coreDivision);
$collection
->expects(static::once())
->method('getDefaultBrowser')
->willReturn($division);
$collection
->expects(static::once())
->method('getDivisions')
->willReturn([$division]);
$dataCollectionFactory = $this->getMockBuilder(DataCollectionFactory::class)
->disableOriginalConstructor()
->onlyMethods(['createDataCollection'])
->getMock();
$dataCollectionFactory
->expects(static::once())
->method('createDataCollection')
->willReturn($collection);
$writerCollection = $this->getMockBuilder(WriterCollection::class)
->disableOriginalConstructor()
->onlyMethods([
'fileStart',
'renderHeader',
'renderAllDivisionsHeader',
'renderSectionHeader',
'renderSectionBody',
'fileEnd',
])
->getMock();
$writerCollection
->expects(static::once())
->method('fileStart')
->willReturnSelf();
$writerCollection
->expects(static::once())
->method('renderHeader')
->willReturnSelf();
$writerCollection
->expects(static::once())
->method('renderAllDivisionsHeader')
->willReturnSelf();
$writerCollection
->expects(static::exactly(3))
->method('renderSectionHeader')
->willReturnSelf();
$writerCollection
->expects(static::exactly(3))
->method('renderSectionBody')
->willReturnSelf();
$writerCollection
->expects(static::once())
->method('fileEnd')
->willReturnSelf();
assert($writerCollection instanceof WriterCollection);
assert($dataCollectionFactory instanceof DataCollectionFactory);
$generator = new BuildGenerator('.', '.', $this->logger, $writerCollection, $dataCollectionFactory);
$generator->setCollectPatternIds(false);
$generator->run('test', new DateTimeImmutable(), false);
} | tests running a build
@throws Exception
@throws AssertionFailedException | testBuild | php | browscap/browscap | tests/BrowscapTest/Generator/BuildGeneratorTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Generator/BuildGeneratorTest.php | MIT |
public function testBuildWithoutZip(): void
{
$useragent = $this->getMockBuilder(UserAgent::class)
->disableOriginalConstructor()
->onlyMethods(['getUserAgent', 'getProperties'])
->getMock();
$useragent
->expects(static::exactly(2))
->method('getUserAgent')
->willReturn('abc');
$useragent
->expects(static::exactly(2))
->method('getProperties')
->willReturn([
'Parent' => 'DefaultProperties',
'Comment' => 'Default Browser',
'Browser' => 'Default Browser',
'Browser_Type' => 'unknown',
'Browser_Bits' => 0,
'Browser_Maker' => 'unknown',
'Browser_Modus' => 'unknown',
'Version' => '0.0',
'MajorVer' => '0',
'MinorVer' => '0',
'Platform' => 'unknown',
'Platform_Version' => 'unknown',
'Platform_Description' => 'unknown',
'Platform_Bits' => 0,
'Platform_Maker' => 'unknown',
'Alpha' => false,
'Beta' => false,
'Win16' => false,
'Win32' => false,
'Win64' => false,
'Frames' => false,
'IFrames' => false,
'Tables' => false,
'Cookies' => false,
'BackgroundSounds' => false,
'JavaScript' => false,
'VBScript' => false,
'JavaApplets' => false,
'ActiveXControls' => false,
'isMobileDevice' => false,
'isTablet' => false,
'isSyndicationReader' => false,
'Crawler' => false,
'isFake' => false,
'isAnonymized' => false,
'isModified' => false,
'CssVersion' => 0,
'AolVersion' => 0,
'Device_Name' => 'unknown',
'Device_Maker' => 'unknown',
'Device_Type' => 'unknown',
'Device_Pointing_Method' => 'unknown',
'Device_Code_Name' => 'unknown',
'Device_Brand_Name' => 'unknown',
'RenderingEngine_Name' => 'unknown',
'RenderingEngine_Version' => 'unknown',
'RenderingEngine_Description' => 'unknown',
'RenderingEngine_Maker' => 'unknown',
'PatternId' => 'resources/core/default-browser.json::u0',
]);
$division = $this->getMockBuilder(Division::class)
->disableOriginalConstructor()
->onlyMethods(['getUserAgents', 'getVersions'])
->getMock();
$division
->expects(static::exactly(2))
->method('getUserAgents')
->willReturn(
[0 => $useragent],
);
$division
->expects(static::once())
->method('getVersions')
->willReturn(['2']);
$defaultProperties = $this->getMockBuilder(UserAgent::class)
->disableOriginalConstructor()
->onlyMethods(['getUserAgent', 'getProperties'])
->getMock();
$defaultProperties
->expects(static::exactly(2))
->method('getUserAgent')
->willReturn('DefaultProperties');
$defaultProperties
->expects(static::exactly(3))
->method('getProperties')
->willReturn([
'Comment' => 'Defaultproperties',
'Browser' => 'Defaultproperties',
'Browser_Type' => 'unknown',
'Browser_Bits' => 0,
'Browser_Maker' => 'unknown',
'Browser_Modus' => 'unknown',
'Version' => '0.0',
'MajorVer' => '0',
'MinorVer' => '0',
'Platform' => 'unknown',
'Platform_Version' => 'unknown',
'Platform_Description' => 'unknown',
'Platform_Bits' => 0,
'Platform_Maker' => 'unknown',
'Alpha' => false,
'Beta' => false,
'Win16' => false,
'Win32' => false,
'Win64' => false,
'Frames' => false,
'IFrames' => false,
'Tables' => false,
'Cookies' => false,
'BackgroundSounds' => false,
'JavaScript' => false,
'VBScript' => false,
'JavaApplets' => false,
'ActiveXControls' => false,
'isMobileDevice' => false,
'isTablet' => false,
'isSyndicationReader' => false,
'Crawler' => false,
'isFake' => false,
'isAnonymized' => false,
'isModified' => false,
'CssVersion' => 0,
'AolVersion' => 0,
'Device_Name' => 'unknown',
'Device_Maker' => 'unknown',
'Device_Type' => 'unknown',
'Device_Pointing_Method' => 'unknown',
'Device_Code_Name' => 'unknown',
'Device_Brand_Name' => 'unknown',
'RenderingEngine_Name' => 'unknown',
'RenderingEngine_Version' => 'unknown',
'RenderingEngine_Description' => 'unknown',
'RenderingEngine_Maker' => 'unknown',
'PatternId' => 'resources/core/default-browser.json::u0',
]);
$coreDivision = $this->getMockBuilder(Division::class)
->disableOriginalConstructor()
->onlyMethods(['getUserAgents'])
->getMock();
$coreDivision
->expects(static::exactly(2))
->method('getUserAgents')
->willReturn(
[0 => $defaultProperties],
);
$collection = $this->getMockBuilder(DataCollection::class)
->disableOriginalConstructor()
->onlyMethods(['getDefaultProperties', 'getDefaultBrowser', 'getDivisions'])
->getMock();
$collection
->expects(static::exactly(2))
->method('getDefaultProperties')
->willReturn($coreDivision);
$collection
->expects(static::once())
->method('getDefaultBrowser')
->willReturn($division);
$collection
->expects(static::once())
->method('getDivisions')
->willReturn([$division]);
$dataCollectionFactory = $this->getMockBuilder(DataCollectionFactory::class)
->disableOriginalConstructor()
->onlyMethods(['createDataCollection'])
->getMock();
$dataCollectionFactory
->expects(static::once())
->method('createDataCollection')
->willReturn($collection);
$writerCollection = $this->getMockBuilder(WriterCollection::class)
->disableOriginalConstructor()
->onlyMethods([
'fileStart',
'renderHeader',
'renderAllDivisionsHeader',
'renderSectionHeader',
'renderSectionBody',
'fileEnd',
])
->getMock();
$writerCollection
->expects(static::once())
->method('fileStart')
->willReturnSelf();
$writerCollection
->expects(static::once())
->method('renderHeader')
->willReturnSelf();
$writerCollection
->expects(static::once())
->method('renderAllDivisionsHeader')
->willReturnSelf();
$writerCollection
->expects(static::exactly(3))
->method('renderSectionHeader')
->willReturnSelf();
$writerCollection
->expects(static::exactly(3))
->method('renderSectionBody')
->willReturnSelf();
$writerCollection
->expects(static::once())
->method('fileEnd')
->willReturnSelf();
assert($writerCollection instanceof WriterCollection);
assert($dataCollectionFactory instanceof DataCollectionFactory);
$generator = new BuildGenerator('.', '.', $this->logger, $writerCollection, $dataCollectionFactory);
$generator->setCollectPatternIds(true);
$generator->run('test', new DateTimeImmutable(), false);
} | tests running a build without generating a zip file
@throws Exception
@throws AssertionFailedException | testBuildWithoutZip | php | browscap/browscap | tests/BrowscapTest/Generator/BuildGeneratorTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Generator/BuildGeneratorTest.php | MIT |
public function testRun(): void
{
$writerCollection = $this->getMockBuilder(WriterCollection::class)
->disableOriginalConstructor()
->onlyMethods([
'fileStart',
'renderHeader',
'renderAllDivisionsHeader',
'renderDivisionFooter',
'renderSectionHeader',
'renderSectionBody',
'fileEnd',
])
->getMock();
$writerCollection->expects(static::once())
->method('fileStart')
->willReturnSelf();
$writerCollection->expects(static::once())
->method('fileEnd')
->willReturnSelf();
$writerCollection->expects(static::once())
->method('renderHeader')
->willReturnSelf();
$writerCollection->expects(static::once())
->method('renderAllDivisionsHeader')
->willReturnSelf();
$writerCollection->expects(static::exactly(3))
->method('renderDivisionFooter')
->willReturnSelf();
$writerCollection->expects(static::exactly(3))
->method('renderSectionHeader')
->willReturnSelf();
$writerCollection->expects(static::exactly(3))
->method('renderSectionBody')
->with(static::callback(static function (array $props) {
// Be sure that PatternId key is removed
return ! array_key_exists('PatternId', $props);
}))
->willReturnSelf();
$division = $this->getMockBuilder(Division::class)
->disableOriginalConstructor()
->onlyMethods(['getUserAgents', 'getVersions'])
->getMock();
$useragent = $this->getMockBuilder(UserAgent::class)
->disableOriginalConstructor()
->onlyMethods(['getUserAgent', 'getProperties'])
->getMock();
$useragent
->expects(static::exactly(2))
->method('getUserAgent')
->willReturn('abc');
$useragent
->expects(static::exactly(2))
->method('getProperties')
->willReturn([
'Parent' => 'Defaultproperties',
'Comment' => 'Default Browser',
'Browser' => 'Default Browser',
'Browser_Type' => 'unknown',
'Browser_Bits' => 0,
'Browser_Maker' => 'unknown',
'Browser_Modus' => 'unknown',
'Version' => '0.0',
'MajorVer' => '0',
'MinorVer' => '0',
'Platform' => 'unknown',
'Platform_Version' => 'unknown',
'Platform_Description' => 'unknown',
'Platform_Bits' => 0,
'Platform_Maker' => 'unknown',
'Alpha' => false,
'Beta' => false,
'Win16' => false,
'Win32' => false,
'Win64' => false,
'Frames' => false,
'IFrames' => false,
'Tables' => false,
'Cookies' => false,
'BackgroundSounds' => false,
'JavaScript' => false,
'VBScript' => false,
'JavaApplets' => false,
'ActiveXControls' => false,
'isMobileDevice' => false,
'isTablet' => false,
'isSyndicationReader' => false,
'Crawler' => false,
'isFake' => false,
'isAnonymized' => false,
'isModified' => false,
'CssVersion' => 0,
'AolVersion' => 0,
'Device_Name' => 'unknown',
'Device_Maker' => 'unknown',
'Device_Type' => 'unknown',
'Device_Pointing_Method' => 'unknown',
'Device_Code_Name' => 'unknown',
'Device_Brand_Name' => 'unknown',
'RenderingEngine_Name' => 'unknown',
'RenderingEngine_Version' => 'unknown',
'RenderingEngine_Description' => 'unknown',
'RenderingEngine_Maker' => 'unknown',
'PatternId' => 'resources/core/default-browser.json::u0',
]);
$defaultProperties = $this->getMockBuilder(UserAgent::class)
->disableOriginalConstructor()
->onlyMethods(['getUserAgent', 'getProperties'])
->getMock();
$defaultProperties
->expects(static::exactly(2))
->method('getUserAgent')
->willReturn('Defaultproperties');
$defaultProperties
->expects(static::exactly(3))
->method('getProperties')
->willReturn(
[
'Comment' => 'Defaultproperties',
'Browser' => 'Defaultproperties',
'Browser_Type' => 'unknown',
'Browser_Bits' => 0,
'Browser_Maker' => 'unknown',
'Browser_Modus' => 'unknown',
'Version' => '0.0',
'MajorVer' => '0',
'MinorVer' => '0',
'Platform' => 'unknown',
'Platform_Version' => 'unknown',
'Platform_Description' => 'unknown',
'Platform_Bits' => 0,
'Platform_Maker' => 'unknown',
'Alpha' => false,
'Beta' => false,
'Win16' => false,
'Win32' => false,
'Win64' => false,
'Frames' => false,
'IFrames' => false,
'Tables' => false,
'Cookies' => false,
'BackgroundSounds' => false,
'JavaScript' => false,
'VBScript' => false,
'JavaApplets' => false,
'ActiveXControls' => false,
'isMobileDevice' => false,
'isTablet' => false,
'isSyndicationReader' => false,
'Crawler' => false,
'isFake' => false,
'isAnonymized' => false,
'isModified' => false,
'CssVersion' => 0,
'AolVersion' => 0,
'Device_Name' => 'unknown',
'Device_Maker' => 'unknown',
'Device_Type' => 'unknown',
'Device_Pointing_Method' => 'unknown',
'Device_Code_Name' => 'unknown',
'Device_Brand_Name' => 'unknown',
'RenderingEngine_Name' => 'unknown',
'RenderingEngine_Version' => 'unknown',
'RenderingEngine_Description' => 'unknown',
'RenderingEngine_Maker' => 'unknown',
'PatternId' => 'resources/core/default-browser.json::u0',
],
);
$division
->expects(static::exactly(2))
->method('getUserAgents')
->willReturn(
[0 => $useragent],
);
$division
->expects(static::once())
->method('getVersions')
->willReturn(['2']);
$coreDivision = $this->getMockBuilder(Division::class)
->disableOriginalConstructor()
->onlyMethods(['getUserAgents'])
->getMock();
$coreDivision
->expects(static::exactly(2))
->method('getUserAgents')
->willReturn(
[0 => $defaultProperties],
);
$collection = $this->getMockBuilder(DataCollection::class)
->disableOriginalConstructor()
->onlyMethods(['getDefaultProperties', 'getDefaultBrowser', 'getDivisions'])
->getMock();
$collection
->expects(static::exactly(2))
->method('getDefaultProperties')
->willReturn($coreDivision);
$collection
->expects(static::once())
->method('getDefaultBrowser')
->willReturn($division);
$collection
->expects(static::once())
->method('getDivisions')
->willReturn([$division]);
$collectionCreator = $this->getMockBuilder(DataCollectionFactory::class)
->disableOriginalConstructor()
->onlyMethods(['createDataCollection'])
->getMock();
$collectionCreator->expects(static::once())
->method('createDataCollection')
->willReturn($collection);
assert($writerCollection instanceof WriterCollection);
assert($collectionCreator instanceof DataCollectionFactory);
BuildHelper::run('test', new DateTimeImmutable(), '.', $this->logger, $writerCollection, $collectionCreator);
} | tests running a build
@throws Exception
@throws AssertionFailedException | testRun | php | browscap/browscap | tests/BrowscapTest/Generator/Helper/BuildHelperTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Generator/Helper/BuildHelperTest.php | MIT |
public function testRunDuplicateDivision(): void
{
$writerCollection = $this->getMockBuilder(WriterCollection::class)
->disableOriginalConstructor()
->onlyMethods([
'fileStart',
'renderHeader',
'renderAllDivisionsHeader',
'renderDivisionFooter',
'renderSectionHeader',
'renderSectionBody',
'fileEnd',
])
->getMock();
$writerCollection->expects(static::once())
->method('fileStart')
->willReturnSelf();
$writerCollection->expects(static::once())
->method('fileEnd')
->willReturnSelf();
$writerCollection->expects(static::once())
->method('renderHeader')
->willReturnSelf();
$writerCollection->expects(static::once())
->method('renderAllDivisionsHeader')
->willReturnSelf();
$writerCollection->expects(static::exactly(4))
->method('renderDivisionFooter')
->willReturnSelf();
$writerCollection->expects(static::exactly(3))
->method('renderSectionHeader')
->willReturnSelf();
$writerCollection->expects(static::exactly(3))
->method('renderSectionBody')
->with(static::callback(static function (array $props) {
// Be sure that PatternId key is removed
return ! array_key_exists('PatternId', $props);
}))
->willReturnSelf();
$division = $this->getMockBuilder(Division::class)
->disableOriginalConstructor()
->onlyMethods(['getUserAgents', 'getVersions'])
->getMock();
$useragent = $this->getMockBuilder(UserAgent::class)
->disableOriginalConstructor()
->onlyMethods(['getUserAgent', 'getProperties'])
->getMock();
$useragent
->expects(static::exactly(3))
->method('getUserAgent')
->willReturn('abc');
$useragent
->expects(static::exactly(3))
->method('getProperties')
->willReturn([
'Parent' => 'Defaultproperties',
'Comment' => 'Default Browser',
'Browser' => 'Default Browser',
'Browser_Type' => 'unknown',
'Browser_Bits' => 0,
'Browser_Maker' => 'unknown',
'Browser_Modus' => 'unknown',
'Version' => '0.0',
'MajorVer' => '0',
'MinorVer' => '0',
'Platform' => 'unknown',
'Platform_Version' => 'unknown',
'Platform_Description' => 'unknown',
'Platform_Bits' => 0,
'Platform_Maker' => 'unknown',
'Alpha' => false,
'Beta' => false,
'Win16' => false,
'Win32' => false,
'Win64' => false,
'Frames' => false,
'IFrames' => false,
'Tables' => false,
'Cookies' => false,
'BackgroundSounds' => false,
'JavaScript' => false,
'VBScript' => false,
'JavaApplets' => false,
'ActiveXControls' => false,
'isMobileDevice' => false,
'isTablet' => false,
'isSyndicationReader' => false,
'Crawler' => false,
'isFake' => false,
'isAnonymized' => false,
'isModified' => false,
'CssVersion' => 0,
'AolVersion' => 0,
'Device_Name' => 'unknown',
'Device_Maker' => 'unknown',
'Device_Type' => 'unknown',
'Device_Pointing_Method' => 'unknown',
'Device_Code_Name' => 'unknown',
'Device_Brand_Name' => 'unknown',
'RenderingEngine_Name' => 'unknown',
'RenderingEngine_Version' => 'unknown',
'RenderingEngine_Description' => 'unknown',
'RenderingEngine_Maker' => 'unknown',
'PatternId' => 'resources/core/default-browser.json::u0',
]);
$division
->expects(static::exactly(3))
->method('getUserAgents')
->willReturn(
[0 => $useragent],
);
$division
->expects(static::exactly(2))
->method('getVersions')
->willReturn(['2']);
$defaultProperties = $this->getMockBuilder(UserAgent::class)
->disableOriginalConstructor()
->onlyMethods(['getUserAgent', 'getProperties'])
->getMock();
$defaultProperties
->expects(static::exactly(3))
->method('getUserAgent')
->willReturn('Defaultproperties');
$defaultProperties
->expects(static::exactly(5))
->method('getProperties')
->willReturn(
[
'Comment' => 'Defaultproperties',
'Browser' => 'Defaultproperties',
'Browser_Type' => 'unknown',
'Browser_Bits' => 0,
'Browser_Maker' => 'unknown',
'Browser_Modus' => 'unknown',
'Version' => '0.0',
'MajorVer' => '0',
'MinorVer' => '0',
'Platform' => 'unknown',
'Platform_Version' => 'unknown',
'Platform_Description' => 'unknown',
'Platform_Bits' => 0,
'Platform_Maker' => 'unknown',
'Alpha' => false,
'Beta' => false,
'Win16' => false,
'Win32' => false,
'Win64' => false,
'Frames' => false,
'IFrames' => false,
'Tables' => false,
'Cookies' => false,
'BackgroundSounds' => false,
'JavaScript' => false,
'VBScript' => false,
'JavaApplets' => false,
'ActiveXControls' => false,
'isMobileDevice' => false,
'isTablet' => false,
'isSyndicationReader' => false,
'Crawler' => false,
'isFake' => false,
'isAnonymized' => false,
'isModified' => false,
'CssVersion' => 0,
'AolVersion' => 0,
'Device_Name' => 'unknown',
'Device_Maker' => 'unknown',
'Device_Type' => 'unknown',
'Device_Pointing_Method' => 'unknown',
'Device_Code_Name' => 'unknown',
'Device_Brand_Name' => 'unknown',
'RenderingEngine_Name' => 'unknown',
'RenderingEngine_Version' => 'unknown',
'RenderingEngine_Description' => 'unknown',
'RenderingEngine_Maker' => 'unknown',
'PatternId' => 'resources/core/default-browser.json::u0',
],
);
$coreDivision = $this->getMockBuilder(Division::class)
->disableOriginalConstructor()
->onlyMethods(['getUserAgents'])
->getMock();
$coreDivision
->expects(static::exactly(3))
->method('getUserAgents')
->willReturn(
[0 => $defaultProperties],
);
$collection = $this->getMockBuilder(DataCollection::class)
->disableOriginalConstructor()
->onlyMethods(['getDefaultProperties', 'getDefaultBrowser', 'getDivisions'])
->getMock();
$collection
->expects(static::exactly(3))
->method('getDefaultProperties')
->willReturn($coreDivision);
$collection
->expects(static::once())
->method('getDefaultBrowser')
->willReturn($division);
$collection
->expects(static::once())
->method('getDivisions')
->willReturn([$division, $division]);
$collectionCreator = $this->getMockBuilder(DataCollectionFactory::class)
->disableOriginalConstructor()
->onlyMethods(['createDataCollection'])
->getMock();
$collectionCreator->expects(static::once())
->method('createDataCollection')
->willReturn($collection);
assert($writerCollection instanceof WriterCollection);
assert($collectionCreator instanceof DataCollectionFactory);
BuildHelper::run('test', new DateTimeImmutable(), '.', $this->logger, $writerCollection, $collectionCreator);
} | tests running a build
@throws Exception
@throws AssertionFailedException | testRunDuplicateDivision | php | browscap/browscap | tests/BrowscapTest/Generator/Helper/BuildHelperTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Generator/Helper/BuildHelperTest.php | MIT |
public function testRunWithPatternIdCollectionEnabled(): void
{
$writerCollection = $this->getMockBuilder(WriterCollection::class)
->disableOriginalConstructor()
->onlyMethods([
'fileStart',
'renderHeader',
'renderAllDivisionsHeader',
'renderDivisionFooter',
'renderSectionHeader',
'renderSectionBody',
'fileEnd',
])
->getMock();
$writerCollection->expects(static::once())
->method('fileStart')
->willReturnSelf();
$writerCollection->expects(static::once())
->method('fileEnd')
->willReturnSelf();
$writerCollection->expects(static::once())
->method('renderHeader')
->willReturnSelf();
$writerCollection->expects(static::once())
->method('renderAllDivisionsHeader')
->willReturnSelf();
$writerCollection->expects(static::exactly(3))
->method('renderDivisionFooter')
->willReturnSelf();
$writerCollection->expects(static::exactly(3))
->method('renderSectionHeader')
->willReturnSelf();
$writerCollection->expects(static::exactly(3))
->method('renderSectionBody')
->with(static::callback(static function (array $props) {
// Be sure that PatternId key is present
return array_key_exists('PatternId', $props);
}))
->willReturnSelf();
$division = $this->getMockBuilder(Division::class)
->disableOriginalConstructor()
->onlyMethods(['getUserAgents', 'getVersions'])
->getMock();
$useragent = $this->getMockBuilder(UserAgent::class)
->disableOriginalConstructor()
->onlyMethods(['getUserAgent', 'getProperties'])
->getMock();
$useragent
->expects(static::exactly(2))
->method('getUserAgent')
->willReturn('abc');
$useragent
->expects(static::exactly(2))
->method('getProperties')
->willReturn([
'Parent' => 'Defaultproperties',
'Comment' => 'Default Browser',
'Browser' => 'Default Browser',
'Browser_Type' => 'unknown',
'Browser_Bits' => 0,
'Browser_Maker' => 'unknown',
'Browser_Modus' => 'unknown',
'Version' => '0.0',
'MajorVer' => '0',
'MinorVer' => '0',
'Platform' => 'unknown',
'Platform_Version' => 'unknown',
'Platform_Description' => 'unknown',
'Platform_Bits' => 0,
'Platform_Maker' => 'unknown',
'Alpha' => false,
'Beta' => false,
'Win16' => false,
'Win32' => false,
'Win64' => false,
'Frames' => false,
'IFrames' => false,
'Tables' => false,
'Cookies' => false,
'BackgroundSounds' => false,
'JavaScript' => false,
'VBScript' => false,
'JavaApplets' => false,
'ActiveXControls' => false,
'isMobileDevice' => false,
'isTablet' => false,
'isSyndicationReader' => false,
'Crawler' => false,
'isFake' => false,
'isAnonymized' => false,
'isModified' => false,
'CssVersion' => 0,
'AolVersion' => 0,
'Device_Name' => 'unknown',
'Device_Maker' => 'unknown',
'Device_Type' => 'unknown',
'Device_Pointing_Method' => 'unknown',
'Device_Code_Name' => 'unknown',
'Device_Brand_Name' => 'unknown',
'RenderingEngine_Name' => 'unknown',
'RenderingEngine_Version' => 'unknown',
'RenderingEngine_Description' => 'unknown',
'RenderingEngine_Maker' => 'unknown',
'PatternId' => 'resources/core/default-browser.json::u0',
]);
$division
->expects(static::exactly(2))
->method('getUserAgents')
->willReturn(
[0 => $useragent],
);
$division
->expects(static::once())
->method('getVersions')
->willReturn(['2']);
$defaultProperties = $this->getMockBuilder(UserAgent::class)
->disableOriginalConstructor()
->onlyMethods(['getUserAgent', 'getProperties'])
->getMock();
$defaultProperties
->expects(static::exactly(2))
->method('getUserAgent')
->willReturn('Defaultproperties');
$defaultProperties
->expects(static::exactly(3))
->method('getProperties')
->willReturn(
[
'Comment' => 'Defaultproperties',
'Browser' => 'Defaultproperties',
'Browser_Type' => 'unknown',
'Browser_Bits' => 0,
'Browser_Maker' => 'unknown',
'Browser_Modus' => 'unknown',
'Version' => '0.0',
'MajorVer' => '0',
'MinorVer' => '0',
'Platform' => 'unknown',
'Platform_Version' => 'unknown',
'Platform_Description' => 'unknown',
'Platform_Bits' => 0,
'Platform_Maker' => 'unknown',
'Alpha' => false,
'Beta' => false,
'Win16' => false,
'Win32' => false,
'Win64' => false,
'Frames' => false,
'IFrames' => false,
'Tables' => false,
'Cookies' => false,
'BackgroundSounds' => false,
'JavaScript' => false,
'VBScript' => false,
'JavaApplets' => false,
'ActiveXControls' => false,
'isMobileDevice' => false,
'isTablet' => false,
'isSyndicationReader' => false,
'Crawler' => false,
'isFake' => false,
'isAnonymized' => false,
'isModified' => false,
'CssVersion' => 0,
'AolVersion' => 0,
'Device_Name' => 'unknown',
'Device_Maker' => 'unknown',
'Device_Type' => 'unknown',
'Device_Pointing_Method' => 'unknown',
'Device_Code_Name' => 'unknown',
'Device_Brand_Name' => 'unknown',
'RenderingEngine_Name' => 'unknown',
'RenderingEngine_Version' => 'unknown',
'RenderingEngine_Description' => 'unknown',
'RenderingEngine_Maker' => 'unknown',
'PatternId' => 'resources/core/default-browser.json::u0',
],
);
$coreDivision = $this->getMockBuilder(Division::class)
->disableOriginalConstructor()
->onlyMethods(['getUserAgents'])
->getMock();
$coreDivision
->expects(static::exactly(2))
->method('getUserAgents')
->willReturn(
[0 => $defaultProperties],
);
$collection = $this->getMockBuilder(DataCollection::class)
->disableOriginalConstructor()
->onlyMethods(['getDefaultProperties', 'getDefaultBrowser', 'getDivisions'])
->getMock();
$collection
->expects(static::exactly(2))
->method('getDefaultProperties')
->willReturn($coreDivision);
$collection
->expects(static::once())
->method('getDefaultBrowser')
->willReturn($division);
$collection
->expects(static::once())
->method('getDivisions')
->willReturn([$division]);
$collectionCreator = $this->getMockBuilder(DataCollectionFactory::class)
->disableOriginalConstructor()
->onlyMethods(['createDataCollection'])
->getMock();
$collectionCreator->expects(static::once())
->method('createDataCollection')
->willReturn($collection);
assert($writerCollection instanceof WriterCollection);
assert($collectionCreator instanceof DataCollectionFactory);
BuildHelper::run('test', new DateTimeImmutable(), '.', $this->logger, $writerCollection, $collectionCreator, true);
} | tests running a build with pattern id collection enabled
@throws Exception
@throws AssertionFailedException | testRunWithPatternIdCollectionEnabled | php | browscap/browscap | tests/BrowscapTest/Generator/Helper/BuildHelperTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Generator/Helper/BuildHelperTest.php | MIT |
public function testConstructorSetsFilename(): void
{
$parser = new IniParser('foobar');
self::assertSame('foobar', $parser->getFilename());
} | tests creating the parser class
@throws ExpectationFailedException
@group parser
@group sourcetest | testConstructorSetsFilename | php | browscap/browscap | tests/BrowscapTest/Parser/IniParserTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Parser/IniParserTest.php | MIT |
public function testSetShouldSort(): void
{
$parser = new IniParser('');
// Test the default value
self::assertFalse($parser->shouldSort());
// Test setting it to true
$parser->setShouldSort(true);
self::assertTrue($parser->shouldSort());
// Test setting it back to false
$parser->setShouldSort(false);
self::assertFalse($parser->shouldSort());
} | tests setting the should sort flag
@throws ExpectationFailedException
@group parser
@group sourcetest | testSetShouldSort | php | browscap/browscap | tests/BrowscapTest/Parser/IniParserTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Parser/IniParserTest.php | MIT |
public static function sortArrayDataProvider(): array
{
return [
'flatArray' => [
['d' => 'lemon', 'a' => 'orange', 'b' => 'banana', 'c' => 'apple'],
['a' => 'orange', 'b' => 'banana', 'c' => 'apple', 'd' => 'lemon'],
],
'twoDimensionalArray' => [
['z' => 'zzz', 'x' => ['b' => 'bbb', 'a' => 'aaa', 'c' => 'ccc'], 'y' => ['k' => 'kkk', 'j' => 'jjj', 'i' => 'iii']],
['x' => ['a' => 'aaa', 'b' => 'bbb', 'c' => 'ccc'], 'y' => ['i' => 'iii', 'j' => 'jjj', 'k' => 'kkk'], 'z' => 'zzz'],
],
];
} | tests setting and getting a logger
@return array<string, array<int, array<string, array<string, string>|string>>>
@throws void | sortArrayDataProvider | php | browscap/browscap | tests/BrowscapTest/Parser/IniParserTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Parser/IniParserTest.php | MIT |
public function testSortArrayAndChildArrays(array $unsorted, array $sorted): void
{
$parser = new IniParser('');
$sortMethod = new ReflectionMethod('\Browscap\Parser\IniParser', 'sortArrayAndChildArrays');
self::assertSame($sorted, $sortMethod->invokeArgs($parser, [$unsorted]));
} | @param array<string> $unsorted
@param array<string> $sorted
@throws ReflectionException
@dataProvider sortArrayDataProvider
@group parser
@group sourcetest | testSortArrayAndChildArrays | php | browscap/browscap | tests/BrowscapTest/Parser/IniParserTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Parser/IniParserTest.php | MIT |
public function testGetLinesFromFileReturnsArrayWithLines(): void
{
$tmpfile = (string) tempnam(sys_get_temp_dir(), 'browscaptest');
$in = <<<'HERE'
; comment
[test]
test=test
HERE;
file_put_contents($tmpfile, $in);
$parser = new IniParser($tmpfile);
$out = $parser->getLinesFromFile();
unlink($tmpfile);
$expected = [
'; comment',
'[test]',
'test=test',
];
self::assertSame($expected, $out);
} | tests getting lines from a file
@throws ExpectationFailedException
@throws InvalidArgumentException
@group parser
@group sourcetest | testGetLinesFromFileReturnsArrayWithLines | php | browscap/browscap | tests/BrowscapTest/Parser/IniParserTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Parser/IniParserTest.php | MIT |
public function testGetLinesFromFileThrowsExceptionIfFileDoesNotExist(): void
{
$file = '/hopefully/this/file/does/not/exist';
$parser = new IniParser($file);
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('File not found: ' . $file);
$parser->getLinesFromFile();
} | tests throwing an exception if the input file does not exist
@throws InvalidArgumentException
@group parser
@group sourcetest | testGetLinesFromFileThrowsExceptionIfFileDoesNotExist | php | browscap/browscap | tests/BrowscapTest/Parser/IniParserTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Parser/IniParserTest.php | MIT |
public function testGetFileLinesReturnsLinesFromFile(): void
{
$tmpfile = (string) tempnam(sys_get_temp_dir(), 'browscaptest');
$in = <<<'HERE'
; comment
[test]
test=test
HERE;
file_put_contents($tmpfile, $in);
$parser = new IniParser($tmpfile);
$out = $parser->getFileLines();
unlink($tmpfile);
$expected = [
'; comment',
'[test]',
'test=test',
];
self::assertSame($expected, $out);
} | tests getting lines from a file
@throws ExpectationFailedException
@throws InvalidArgumentException
@group parser
@group sourcetest | testGetFileLinesReturnsLinesFromFile | php | browscap/browscap | tests/BrowscapTest/Parser/IniParserTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Parser/IniParserTest.php | MIT |
public function testGetFileLinesReturnsLinesFromPreviouslySetLines(): void
{
$lines = ['first', 'second', 'third'];
$parser = new IniParser('');
$parser->setFileLines($lines);
self::assertSame($lines, $parser->getFileLines());
} | tests setting and getting lines of a file
@throws ExpectationFailedException
@throws InvalidArgumentException
@group parser
@group sourcetest | testGetFileLinesReturnsLinesFromPreviouslySetLines | php | browscap/browscap | tests/BrowscapTest/Parser/IniParserTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Parser/IniParserTest.php | MIT |
public function testParseWithoutSorting(): void
{
$lines = [
'',
';;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; division1',
'',
'; this line is a comment',
'[section1]',
'property11=value11',
'property12=value12',
'',
'; this line is a comment',
'[section2]',
'property21=value21',
'property22=value22',
'',
';;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; division2',
'',
'; this line is a comment',
'[section3]',
'property31=value31',
'property32=value32',
'property33',
];
$parser = new IniParser('');
$parser->setFileLines($lines);
$parser->setShouldSort(true);
$expected = [
'section1' => ['Division' => 'division1', 'property11' => 'value11', 'property12' => 'value12'],
'section2' => ['Division' => 'division1', 'property21' => 'value21', 'property22' => 'value22'],
'section3' => ['Division' => 'division2', 'property31' => 'value31', 'property32' => 'value32', 'property33' => ''],
];
$data = $parser->parse();
self::assertSame($data, $parser->getParsed());
self::assertSame($expected, $data);
} | tests parsing sections without sorting
@throws ExpectationFailedException
@throws RuntimeException
@throws InvalidArgumentException
@group parser
@group sourcetest | testParseWithoutSorting | php | browscap/browscap | tests/BrowscapTest/Parser/IniParserTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Parser/IniParserTest.php | MIT |
public function testParseWithSorting(): void
{
$lines = [
'',
';;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; division1',
'',
'; this line is a comment',
'[section1]',
'property11=value11',
'property12=value12',
'',
'; this line is a comment',
'[section2]',
'property21=value21',
'property22=value22',
'',
';;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; division2',
'',
'; this line is a comment',
'[section3]',
'property31=value31',
'property32=value32',
];
$parser = new IniParser('');
$parser->setFileLines($lines);
$parser->setShouldSort(true);
$expected = [
'section1' => ['Division' => 'division1', 'property11' => 'value11', 'property12' => 'value12'],
'section2' => ['Division' => 'division1', 'property21' => 'value21', 'property22' => 'value22'],
'section3' => ['Division' => 'division2', 'property31' => 'value31', 'property32' => 'value32'],
];
$data = $parser->parse();
self::assertSame($expected, $data);
} | tests parsing sections with sorting
@throws ExpectationFailedException
@throws RuntimeException
@throws InvalidArgumentException
@group parser
@group sourcetest | testParseWithSorting | php | browscap/browscap | tests/BrowscapTest/Parser/IniParserTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Parser/IniParserTest.php | MIT |
public function testParseThrowsExceptionWhenInvalidFormatting(): void
{
$lines = ['double=equals=here'];
$parser = new IniParser('');
$parser->setFileLines($lines);
$this->expectException(RuntimeException::class);
$this->expectExceptionMessage('Too many equals in line: double=equals=here');
$parser->parse();
} | tests throwing an exception if more than one eual sign is present in a line
@throws RuntimeException
@throws InvalidArgumentException
@group parser
@group sourcetest | testParseThrowsExceptionWhenInvalidFormatting | php | browscap/browscap | tests/BrowscapTest/Parser/IniParserTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Parser/IniParserTest.php | MIT |
public function testGetType(): void
{
static::assertSame(WriterInterface::TYPE_CSV, $this->object->getType());
} | tests getting the writer type
@throws ExpectationFailedException | testGetType | php | browscap/browscap | tests/BrowscapTest/Writer/CsvWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/CsvWriterTest.php | MIT |
public function testSetGetFormatter(): void
{
$mockFormatter = $this->createMock(CsvFormatter::class);
assert($mockFormatter instanceof CsvFormatter);
$this->object->setFormatter($mockFormatter);
static::assertSame($mockFormatter, $this->object->getFormatter());
} | tests setting and getting a formatter
@throws ExpectationFailedException | testSetGetFormatter | php | browscap/browscap | tests/BrowscapTest/Writer/CsvWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/CsvWriterTest.php | MIT |
public function testSetGetFilter(): void
{
$mockFilter = $this->createMock(FullFilter::class);
assert($mockFilter instanceof FullFilter);
$this->object->setFilter($mockFilter);
static::assertSame($mockFilter, $this->object->getFilter());
} | tests setting and getting a filter
@throws ExpectationFailedException | testSetGetFilter | php | browscap/browscap | tests/BrowscapTest/Writer/CsvWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/CsvWriterTest.php | MIT |
public function testSetGetSilent(): void
{
$this->object->setSilent(true);
static::assertTrue($this->object->isSilent());
} | tests setting a file into silent mode
@throws ExpectationFailedException | testSetGetSilent | php | browscap/browscap | tests/BrowscapTest/Writer/CsvWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/CsvWriterTest.php | MIT |
public function testFileStart(): void
{
$this->object->fileStart();
static::assertSame('', file_get_contents($this->file));
} | tests rendering the start of the file
@throws ExpectationFailedException | testFileStart | php | browscap/browscap | tests/BrowscapTest/Writer/CsvWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/CsvWriterTest.php | MIT |
public function testFileEnd(): void
{
$this->object->fileEnd();
static::assertSame('', file_get_contents($this->file));
} | tests rendering the end of the file
@throws ExpectationFailedException | testFileEnd | php | browscap/browscap | tests/BrowscapTest/Writer/CsvWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/CsvWriterTest.php | MIT |
public function testRenderHeader(): void
{
$header = ['TestData to be renderd into the Header'];
$this->object->renderHeader($header);
static::assertSame('', file_get_contents($this->file));
} | tests rendering the header information
@throws ExpectationFailedException | testRenderHeader | php | browscap/browscap | tests/BrowscapTest/Writer/CsvWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/CsvWriterTest.php | MIT |
public function testRenderVersionIfSilent(): void
{
$version = [
'version' => 'test',
'released' => date('Y-m-d'),
'format' => 'TEST',
'type' => 'full',
];
$this->object->setSilent(true);
$this->object->renderVersion($version);
static::assertSame('', file_get_contents($this->file));
} | tests rendering the version information
@throws ExpectationFailedException | testRenderVersionIfSilent | php | browscap/browscap | tests/BrowscapTest/Writer/CsvWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/CsvWriterTest.php | MIT |
public function testRenderVersionIfNotSilent(): void
{
$version = [
'version' => 'test',
'released' => date('Y-m-d'),
'format' => 'TEST',
'type' => 'full',
];
$this->object->setSilent(false);
$this->object->renderVersion($version);
static::assertSame(
'"GJK_Browscap_Version","GJK_Browscap_Version"' . PHP_EOL . '"test","' . date('Y-m-d') . '"' . PHP_EOL,
file_get_contents($this->file),
);
} | tests rendering the version information
@throws ExpectationFailedException | testRenderVersionIfNotSilent | php | browscap/browscap | tests/BrowscapTest/Writer/CsvWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/CsvWriterTest.php | MIT |
public function testRenderVersionIfNotSilentButWithoutVersion(): void
{
$version = [];
$this->object->setSilent(false);
$this->object->renderVersion($version);
static::assertSame(
'"GJK_Browscap_Version","GJK_Browscap_Version"' . PHP_EOL . '"0",""' . PHP_EOL,
file_get_contents($this->file),
);
} | tests rendering the version information
@throws ExpectationFailedException | testRenderVersionIfNotSilentButWithoutVersion | php | browscap/browscap | tests/BrowscapTest/Writer/CsvWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/CsvWriterTest.php | MIT |
public function testRenderAllDivisionsHeader(): void
{
$useragent = $this->getMockBuilder(UserAgent::class)
->disableOriginalConstructor()
->onlyMethods(['getProperties'])
->getMock();
$useragent
->expects(static::exactly(2))
->method('getProperties')
->willReturn([
'Test' => 1,
'isTest' => true,
]);
$division = $this->getMockBuilder(Division::class)
->disableOriginalConstructor()
->onlyMethods(['getUserAgents'])
->getMock();
$division
->expects(static::once())
->method('getUserAgents')
->willReturn([0 => $useragent]);
$collection = $this->getMockBuilder(DataCollection::class)
->disableOriginalConstructor()
->onlyMethods(['getDefaultProperties'])
->getMock();
$collection
->expects(static::once())
->method('getDefaultProperties')
->willReturn($division);
$mockFormatter = $this->getMockBuilder(CsvFormatter::class)
->disableOriginalConstructor()
->onlyMethods(['formatPropertyName'])
->getMock();
$mockFormatter
->expects(static::exactly(2))
->method('formatPropertyName')
->willReturnArgument(0);
assert($mockFormatter instanceof CsvFormatter);
$this->object->setFormatter($mockFormatter);
$mockFilter = $this->getMockBuilder(FullFilter::class)
->disableOriginalConstructor()
->onlyMethods(['isOutputProperty'])
->getMock();
$map = [
['Test', $this->object, true],
['isTest', $this->object, false],
['abc', $this->object, true],
['PropertyName', $this->object, false],
['MasterParent', $this->object, false],
['LiteMode', $this->object, false],
['Parent', $this->object, true],
['alpha', $this->object, true],
];
$mockFilter
->expects(static::exactly(6))
->method('isOutputProperty')
->willReturnMap($map);
assert($mockFilter instanceof FullFilter);
$this->object->setFilter($mockFilter);
assert($collection instanceof DataCollection);
$this->object->renderAllDivisionsHeader($collection);
static::assertSame('Parent,Test' . PHP_EOL, file_get_contents($this->file));
} | tests rendering the header for all division
@throws ExpectationFailedException
@throws JsonException | testRenderAllDivisionsHeader | php | browscap/browscap | tests/BrowscapTest/Writer/CsvWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/CsvWriterTest.php | MIT |
public function testRenderAllDivisionsHeaderWithoutProperties(): void
{
$useragent = $this->getMockBuilder(UserAgent::class)
->disableOriginalConstructor()
->onlyMethods(['getProperties'])
->getMock();
$useragent
->expects(static::once())
->method('getProperties')
->willReturn([]);
$division = $this->getMockBuilder(Division::class)
->disableOriginalConstructor()
->onlyMethods(['getUserAgents'])
->getMock();
$division
->expects(static::once())
->method('getUserAgents')
->willReturn([0 => $useragent]);
$collection = $this->getMockBuilder(DataCollection::class)
->disableOriginalConstructor()
->onlyMethods(['getDefaultProperties'])
->getMock();
$collection
->expects(static::once())
->method('getDefaultProperties')
->willReturn($division);
assert($collection instanceof DataCollection);
$this->object->renderAllDivisionsHeader($collection);
static::assertSame('', file_get_contents($this->file));
} | tests rendering the header for all division
@throws ExpectationFailedException
@throws JsonException | testRenderAllDivisionsHeaderWithoutProperties | php | browscap/browscap | tests/BrowscapTest/Writer/CsvWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/CsvWriterTest.php | MIT |
public function testRenderDivisionHeader(): void
{
$this->object->renderDivisionHeader('test');
static::assertSame('', file_get_contents($this->file));
} | tests rendering the header of one division
@throws ExpectationFailedException | testRenderDivisionHeader | php | browscap/browscap | tests/BrowscapTest/Writer/CsvWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/CsvWriterTest.php | MIT |
public function testRenderSectionHeader(): void
{
$this->object->renderSectionHeader('test');
static::assertSame('', file_get_contents($this->file));
} | tests rendering the header of one section
@throws ExpectationFailedException | testRenderSectionHeader | php | browscap/browscap | tests/BrowscapTest/Writer/CsvWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/CsvWriterTest.php | MIT |
public function testRenderSectionBodyIfNotSilent(): void
{
$this->object->setSilent(false);
$section = [
'Test' => 1,
'isTest' => true,
'abc' => 'bcd',
];
$useragent = $this->getMockBuilder(UserAgent::class)
->disableOriginalConstructor()
->onlyMethods(['getProperties'])
->getMock();
$useragent
->expects(static::once())
->method('getProperties')
->willReturn([
'Test' => 'abc',
'abc' => true,
'alpha' => true,
]);
$division = $this->getMockBuilder(Division::class)
->disableOriginalConstructor()
->onlyMethods(['getUserAgents'])
->getMock();
$division
->expects(static::once())
->method('getUserAgents')
->willReturn([0 => $useragent]);
$collection = $this->getMockBuilder(DataCollection::class)
->disableOriginalConstructor()
->onlyMethods(['getDefaultProperties'])
->getMock();
$collection
->expects(static::once())
->method('getDefaultProperties')
->willReturn($division);
$mockFormatter = $this->getMockBuilder(CsvFormatter::class)
->disableOriginalConstructor()
->onlyMethods(['formatPropertyName', 'formatPropertyValue'])
->getMock();
$map1 = [
['', 'Parent', ''],
[1, 'Test', '1'],
['bcd', 'abc', 'bcd'],
['', 'alpha', ''],
];
$mockFormatter
->expects(static::exactly(4))
->method('formatPropertyValue')
->willReturnMap($map1);
$mockFormatter
->expects(static::never())
->method('formatPropertyName');
assert($mockFormatter instanceof CsvFormatter);
$this->object->setFormatter($mockFormatter);
$mockFilter = $this->getMockBuilder(FullFilter::class)
->disableOriginalConstructor()
->onlyMethods(['isOutputProperty'])
->getMock();
$map2 = [
['Test', $this->object, true],
['isTest', $this->object, false],
['abc', $this->object, true],
['PropertyName', $this->object, false],
['MasterParent', $this->object, false],
['LiteMode', $this->object, false],
['Parent', $this->object, true],
['alpha', $this->object, true],
];
$mockFilter
->expects(static::exactly(7))
->method('isOutputProperty')
->willReturnMap($map2);
assert($mockFilter instanceof FullFilter);
$this->object->setFilter($mockFilter);
assert($collection instanceof DataCollection);
$this->object->renderSectionBody($section, $collection);
static::assertSame(',1,bcd,' . PHP_EOL, file_get_contents($this->file));
} | tests rendering the body of one section
@throws ExpectationFailedException
@throws InvalidArgumentException
@throws Exception
@throws JsonException | testRenderSectionBodyIfNotSilent | php | browscap/browscap | tests/BrowscapTest/Writer/CsvWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/CsvWriterTest.php | MIT |
public function testRenderSectionBodyIfSilent(): void
{
$this->object->setSilent(true);
$section = [
'Test' => 1,
'isTest' => true,
'abc' => 'bcd',
];
$collection = $this->createMock(DataCollection::class);
assert($collection instanceof DataCollection);
$this->object->renderSectionBody($section, $collection);
static::assertSame('', file_get_contents($this->file));
} | tests rendering the body of one section
@throws ExpectationFailedException
@throws InvalidArgumentException
@throws Exception
@throws JsonException | testRenderSectionBodyIfSilent | php | browscap/browscap | tests/BrowscapTest/Writer/CsvWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/CsvWriterTest.php | MIT |
public function testRenderSectionFooter(): void
{
$this->object->renderSectionFooter();
static::assertSame('', file_get_contents($this->file));
} | tests rendering the footer of one section
@throws ExpectationFailedException | testRenderSectionFooter | php | browscap/browscap | tests/BrowscapTest/Writer/CsvWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/CsvWriterTest.php | MIT |
public function testRenderDivisionFooter(): void
{
$this->object->renderDivisionFooter();
static::assertSame('', file_get_contents($this->file));
} | tests rendering the footer of one division
@throws ExpectationFailedException | testRenderDivisionFooter | php | browscap/browscap | tests/BrowscapTest/Writer/CsvWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/CsvWriterTest.php | MIT |
public function testRenderAllDivisionsFooter(): void
{
$this->object->renderAllDivisionsFooter();
static::assertSame('', file_get_contents($this->file));
} | tests rendering the footer after all divisions
@throws ExpectationFailedException | testRenderAllDivisionsFooter | php | browscap/browscap | tests/BrowscapTest/Writer/CsvWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/CsvWriterTest.php | MIT |
public function testGetType(): void
{
static::assertSame(WriterInterface::TYPE_INI, $this->object->getType());
} | tests getting the writer type
@throws ExpectationFailedException | testGetType | php | browscap/browscap | tests/BrowscapTest/Writer/IniWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/IniWriterTest.php | MIT |
public function testSetGetFormatter(): void
{
$mockFormatter = $this->createMock(PhpFormatter::class);
assert($mockFormatter instanceof PhpFormatter);
$this->object->setFormatter($mockFormatter);
static::assertSame($mockFormatter, $this->object->getFormatter());
} | tests setting and getting a formatter
@throws ExpectationFailedException | testSetGetFormatter | php | browscap/browscap | tests/BrowscapTest/Writer/IniWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/IniWriterTest.php | MIT |
public function testSetGetFilter(): void
{
$mockFilter = $this->createMock(FullFilter::class);
assert($mockFilter instanceof FullFilter);
$this->object->setFilter($mockFilter);
static::assertSame($mockFilter, $this->object->getFilter());
} | tests setting and getting a filter
@throws ExpectationFailedException | testSetGetFilter | php | browscap/browscap | tests/BrowscapTest/Writer/IniWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/IniWriterTest.php | MIT |
public function testSetGetSilent(): void
{
$this->object->setSilent(true);
static::assertTrue($this->object->isSilent());
} | tests setting a file into silent mode
@throws ExpectationFailedException | testSetGetSilent | php | browscap/browscap | tests/BrowscapTest/Writer/IniWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/IniWriterTest.php | MIT |
public function testFileStart(): void
{
$this->object->fileStart();
static::assertSame('', file_get_contents($this->file));
} | tests rendering the start of the file
@throws ExpectationFailedException | testFileStart | php | browscap/browscap | tests/BrowscapTest/Writer/IniWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/IniWriterTest.php | MIT |
public function testFileEnd(): void
{
$this->object->fileEnd();
static::assertSame('', file_get_contents($this->file));
} | tests rendering the end of the file
@throws ExpectationFailedException | testFileEnd | php | browscap/browscap | tests/BrowscapTest/Writer/IniWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/IniWriterTest.php | MIT |
public function testRenderHeaderIfSilent(): void
{
$header = ['TestData to be renderd into the Header'];
$this->object->setSilent(true);
$this->object->renderHeader($header);
static::assertSame('', file_get_contents($this->file));
} | tests rendering the header information
@throws ExpectationFailedException | testRenderHeaderIfSilent | php | browscap/browscap | tests/BrowscapTest/Writer/IniWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/IniWriterTest.php | MIT |
public function testRenderHeaderIfNotSilent(): void
{
$header = ['TestData to be rendered into the Header', 'more data to be rendered', 'much more data'];
$this->object->setSilent(false);
$this->object->renderHeader($header);
static::assertSame(
';;; TestData to be rendered into the Header' . PHP_EOL
. ';;; more data to be rendered' . PHP_EOL
. ';;; much more data' . PHP_EOL . PHP_EOL,
file_get_contents($this->file),
);
} | tests rendering the header information
@throws ExpectationFailedException | testRenderHeaderIfNotSilent | php | browscap/browscap | tests/BrowscapTest/Writer/IniWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/IniWriterTest.php | MIT |
public function testRenderVersionIfSilent(): void
{
$version = [
'version' => 'test',
'released' => date('Y-m-d'),
'format' => 'TEST',
'type' => 'full',
];
$this->object->setSilent(true);
$this->object->renderVersion($version);
static::assertSame('', file_get_contents($this->file));
} | tests rendering the version information
@throws ExpectationFailedException | testRenderVersionIfSilent | php | browscap/browscap | tests/BrowscapTest/Writer/IniWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/IniWriterTest.php | MIT |
public function testRenderVersionIfNotSilent(): void
{
$version = [
'version' => 'test',
'released' => date('Y-m-d'),
'format' => 'TEST',
'type' => 'full',
];
$this->object->setSilent(false);
$this->object->renderVersion($version);
static::assertSame(
';;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Browscap Version' . PHP_EOL . PHP_EOL . '[GJK_Browscap_Version]'
. PHP_EOL . 'Version=test' . PHP_EOL . 'Released=' . date('Y-m-d') . PHP_EOL . 'Format=TEST' . PHP_EOL
. 'Type=full' . PHP_EOL . PHP_EOL,
file_get_contents($this->file),
);
} | tests rendering the version information
@throws ExpectationFailedException | testRenderVersionIfNotSilent | php | browscap/browscap | tests/BrowscapTest/Writer/IniWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/IniWriterTest.php | MIT |
public function testRenderVersionIfNotSilentButWithoutVersion(): void
{
$version = [];
$this->object->setSilent(false);
$this->object->renderVersion($version);
static::assertSame(
';;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Browscap Version' . PHP_EOL . PHP_EOL . '[GJK_Browscap_Version]'
. PHP_EOL . 'Version=0' . PHP_EOL . 'Released=' . PHP_EOL . 'Format=' . PHP_EOL . 'Type='
. PHP_EOL . PHP_EOL,
file_get_contents($this->file),
);
} | tests rendering the version information
@throws ExpectationFailedException | testRenderVersionIfNotSilentButWithoutVersion | php | browscap/browscap | tests/BrowscapTest/Writer/IniWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/IniWriterTest.php | MIT |
public function testRenderAllDivisionsHeader(): void
{
$collection = $this->createMock(DataCollection::class);
assert($collection instanceof DataCollection);
$this->object->renderAllDivisionsHeader($collection);
static::assertSame('', file_get_contents($this->file));
} | tests rendering the header for all division
@throws ExpectationFailedException | testRenderAllDivisionsHeader | php | browscap/browscap | tests/BrowscapTest/Writer/IniWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/IniWriterTest.php | MIT |
public function testRenderDivisionHeaderIfNotSilent(): void
{
$this->object->setSilent(false);
$this->object->renderDivisionHeader('test');
static::assertSame(
';;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; test' . PHP_EOL . PHP_EOL,
file_get_contents($this->file),
);
} | tests rendering the header of one division
@throws ExpectationFailedException | testRenderDivisionHeaderIfNotSilent | php | browscap/browscap | tests/BrowscapTest/Writer/IniWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/IniWriterTest.php | MIT |
public function testRenderDivisionHeaderIfSilent(): void
{
$this->object->setSilent(true);
$this->object->renderDivisionHeader('test');
static::assertSame('', file_get_contents($this->file));
} | tests rendering the header of one division
@throws ExpectationFailedException | testRenderDivisionHeaderIfSilent | php | browscap/browscap | tests/BrowscapTest/Writer/IniWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/IniWriterTest.php | MIT |
public function testRenderSectionHeaderIfNotSilent(): void
{
$this->object->setSilent(false);
$this->object->renderSectionHeader('test');
static::assertSame('[test]' . PHP_EOL, file_get_contents($this->file));
} | tests rendering the header of one section
@throws ExpectationFailedException | testRenderSectionHeaderIfNotSilent | php | browscap/browscap | tests/BrowscapTest/Writer/IniWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/IniWriterTest.php | MIT |
public function testRenderSectionHeaderIfSilent(): void
{
$this->object->setSilent(true);
$this->object->renderSectionHeader('test');
static::assertSame('', file_get_contents($this->file));
} | tests rendering the header of one section
@throws ExpectationFailedException | testRenderSectionHeaderIfSilent | php | browscap/browscap | tests/BrowscapTest/Writer/IniWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/IniWriterTest.php | MIT |
public function testRenderSectionBodyIfNotSilent(): void
{
$this->object->setSilent(false);
$section = [
'Comment' => '1',
'Win16' => true,
'Platform' => 'bcd',
];
$useragent = $this->getMockBuilder(UserAgent::class)
->disableOriginalConstructor()
->onlyMethods(['getProperties'])
->getMock();
$useragent
->expects(static::once())
->method('getProperties')
->willReturn([
'Comment' => '1',
'Win16' => true,
]);
$mockExpander = $this->getMockBuilder(TrimProperty::class)
->disableOriginalConstructor()
->onlyMethods(['trim'])
->getMock();
$mockExpander
->expects(static::once())
->method('trim')
->willReturnArgument(0);
$property = new ReflectionProperty($this->object, 'trimProperty');
$property->setValue($this->object, $mockExpander);
$division = $this->getMockBuilder(Division::class)
->disableOriginalConstructor()
->onlyMethods(['getUserAgents'])
->getMock();
$division
->expects(static::once())
->method('getUserAgents')
->willReturn([0 => $useragent]);
$collection = $this->getMockBuilder(DataCollection::class)
->disableOriginalConstructor()
->onlyMethods(['getDefaultProperties'])
->getMock();
$collection
->expects(static::once())
->method('getDefaultProperties')
->willReturn($division);
$propertyHolder = $this->getMockBuilder(PropertyHolder::class)
->disableOriginalConstructor()
->onlyMethods(['getPropertyType'])
->getMock();
$propertyHolder
->expects(static::never())
->method('getPropertyType');
$map1a = [
['Comment', 'Comment'],
];
$map1b = [
['1', 'Comment', '"1"'],
];
$mockFormatter = $this->getMockBuilder(PhpFormatter::class)
->setConstructorArgs([$propertyHolder])
->onlyMethods(['formatPropertyName', 'formatPropertyValue'])
->getMock();
$mockFormatter
->expects(static::once())
->method('formatPropertyName')
->willReturnMap($map1a);
$mockFormatter
->expects(static::once())
->method('formatPropertyValue')
->willReturnMap($map1b);
assert($mockFormatter instanceof PhpFormatter);
$this->object->setFormatter($mockFormatter);
$mockFilter = $this->getMockBuilder(FullFilter::class)
->setConstructorArgs([$propertyHolder])
->onlyMethods(['isOutputProperty'])
->getMock();
$map2 = [
['Comment', $this->object, true],
['Win16', $this->object, false],
['Platform', $this->object, true],
];
$mockFilter
->expects(static::exactly(2))
->method('isOutputProperty')
->willReturnMap($map2);
assert($mockFilter instanceof FullFilter);
$this->object->setFilter($mockFilter);
assert($collection instanceof DataCollection);
$this->object->renderSectionBody($section, $collection);
static::assertSame('Comment="1"' . PHP_EOL, file_get_contents($this->file));
} | tests rendering the body of one section
@throws ReflectionException
@throws InvalidArgumentException
@throws Exception
@throws JsonException | testRenderSectionBodyIfNotSilent | php | browscap/browscap | tests/BrowscapTest/Writer/IniWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/IniWriterTest.php | MIT |
public function testRenderSectionBodyIfNotSilentWithParents(): void
{
$this->object->setSilent(false);
$section = [
'Parent' => 'X1',
'Comment' => '1',
'Win16' => true,
'Platform' => 'bcd',
];
$sections = [
'X1' => [
'Comment' => '12',
'Win16' => false,
'Platform' => 'bcd',
],
'X2' => $section,
];
$mockExpander = $this->getMockBuilder(TrimProperty::class)
->disableOriginalConstructor()
->onlyMethods(['trim'])
->getMock();
$mockExpander
->expects(static::exactly(2))
->method('trim')
->willReturnArgument(0);
$property = new ReflectionProperty($this->object, 'trimProperty');
$property->setValue($this->object, $mockExpander);
$useragent = $this->getMockBuilder(UserAgent::class)
->disableOriginalConstructor()
->onlyMethods(['getProperties'])
->getMock();
$useragent
->expects(static::once())
->method('getProperties')
->willReturn([
'Comment' => 1,
'Win16' => true,
'Platform' => 'bcd',
]);
$division = $this->getMockBuilder(Division::class)
->disableOriginalConstructor()
->onlyMethods(['getUserAgents'])
->getMock();
$division
->expects(static::once())
->method('getUserAgents')
->willReturn([0 => $useragent]);
$collection = $this->getMockBuilder(DataCollection::class)
->disableOriginalConstructor()
->onlyMethods(['getDefaultProperties'])
->getMock();
$collection
->expects(static::once())
->method('getDefaultProperties')
->willReturn($division);
$propertyHolder = $this->getMockBuilder(PropertyHolder::class)
->disableOriginalConstructor()
->onlyMethods(['getPropertyType'])
->getMock();
$propertyHolder
->expects(static::exactly(2))
->method('getPropertyType')
->willReturn(PropertyHolder::TYPE_STRING);
$mockFormatter = $this->getMockBuilder(PhpFormatter::class)
->setConstructorArgs([$propertyHolder])
->onlyMethods(['formatPropertyName'])
->getMock();
$mockFormatter
->expects(static::exactly(2))
->method('formatPropertyName')
->willReturnArgument(0);
assert($mockFormatter instanceof PhpFormatter);
$this->object->setFormatter($mockFormatter);
$map = [
['Comment', $this->object, true],
['Win16', $this->object, false],
['Platform', $this->object, true],
['Parent', $this->object, true],
];
$mockFilter = $this->getMockBuilder(FullFilter::class)
->setConstructorArgs([$propertyHolder])
->onlyMethods(['isOutputProperty'])
->getMock();
$mockFilter
->expects(static::exactly(4))
->method('isOutputProperty')
->willReturnMap($map);
assert($mockFilter instanceof FullFilter);
$this->object->setFilter($mockFilter);
assert($collection instanceof DataCollection);
$this->object->renderSectionBody($section, $collection, $sections);
static::assertSame('Parent="X1"' . PHP_EOL . 'Comment="1"' . PHP_EOL, file_get_contents($this->file));
} | tests rendering the body of one section
@throws ReflectionException
@throws InvalidArgumentException
@throws Exception
@throws JsonException | testRenderSectionBodyIfNotSilentWithParents | php | browscap/browscap | tests/BrowscapTest/Writer/IniWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/IniWriterTest.php | MIT |
public function testRenderSectionBodyIfNotSilentWithDefaultPropertiesAsParent(): void
{
$this->object->setSilent(false);
$section = [
'Parent' => 'DefaultProperties',
'Comment' => '1',
'Win16' => true,
'Platform' => 'bcd',
];
$sections = ['X2' => $section];
$useragent = $this->getMockBuilder(UserAgent::class)
->disableOriginalConstructor()
->onlyMethods(['getProperties'])
->getMock();
$useragent
->expects(static::once())
->method('getProperties')
->willReturn([
'Comment' => '12',
'Win16' => true,
'Platform' => 'bcd',
]);
$mockExpander = $this->getMockBuilder(TrimProperty::class)
->disableOriginalConstructor()
->onlyMethods(['trim'])
->getMock();
$mockExpander
->expects(static::exactly(2))
->method('trim')
->willReturnArgument(0);
$property = new ReflectionProperty($this->object, 'trimProperty');
$property->setValue($this->object, $mockExpander);
$division = $this->getMockBuilder(Division::class)
->disableOriginalConstructor()
->onlyMethods(['getUserAgents'])
->getMock();
$division
->expects(static::once())
->method('getUserAgents')
->willReturn([0 => $useragent]);
$collection = $this->getMockBuilder(DataCollection::class)
->disableOriginalConstructor()
->onlyMethods(['getDefaultProperties'])
->getMock();
$collection
->expects(static::once())
->method('getDefaultProperties')
->willReturn($division);
$propertyHolder = $this->getMockBuilder(PropertyHolder::class)
->disableOriginalConstructor()
->onlyMethods(['getPropertyType'])
->getMock();
$propertyHolder
->expects(static::exactly(2))
->method('getPropertyType')
->willReturn(PropertyHolder::TYPE_STRING);
$mockFormatter = $this->getMockBuilder(PhpFormatter::class)
->setConstructorArgs([$propertyHolder])
->onlyMethods(['formatPropertyName'])
->getMock();
$mockFormatter
->expects(static::exactly(2))
->method('formatPropertyName')
->willReturnArgument(0);
assert($mockFormatter instanceof PhpFormatter);
$this->object->setFormatter($mockFormatter);
$map = [
['Comment', $this->object, true],
['Win16', $this->object, false],
['Platform', $this->object, true],
['Parent', $this->object, true],
];
$mockFilter = $this->getMockBuilder(FullFilter::class)
->setConstructorArgs([$propertyHolder])
->onlyMethods(['isOutputProperty'])
->getMock();
$mockFilter
->expects(static::exactly(4))
->method('isOutputProperty')
->willReturnMap($map);
assert($mockFilter instanceof FullFilter);
$this->object->setFilter($mockFilter);
assert($collection instanceof DataCollection);
$this->object->renderSectionBody($section, $collection, $sections);
static::assertSame(
'Parent="DefaultProperties"' . PHP_EOL . 'Comment="1"' . PHP_EOL,
file_get_contents($this->file),
);
} | tests rendering the body of one section
@throws ReflectionException
@throws InvalidArgumentException
@throws Exception
@throws JsonException | testRenderSectionBodyIfNotSilentWithDefaultPropertiesAsParent | php | browscap/browscap | tests/BrowscapTest/Writer/IniWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/IniWriterTest.php | MIT |
public function testRenderSectionBodyIfSilent(): void
{
$this->object->setSilent(true);
$section = [
'Test' => 1,
'isTest' => true,
'abc' => 'bcd',
];
$collection = $this->createMock(DataCollection::class);
assert($collection instanceof DataCollection);
$this->object->renderSectionBody($section, $collection);
static::assertSame('', file_get_contents($this->file));
} | tests rendering the body of one section
@throws ExpectationFailedException
@throws InvalidArgumentException
@throws Exception
@throws JsonException | testRenderSectionBodyIfSilent | php | browscap/browscap | tests/BrowscapTest/Writer/IniWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/IniWriterTest.php | MIT |
public function testRenderSectionFooterIfNotSilent(): void
{
$this->object->setSilent(false);
$this->object->renderSectionFooter();
static::assertSame(PHP_EOL, file_get_contents($this->file));
} | tests rendering the footer of one section
@throws ExpectationFailedException | testRenderSectionFooterIfNotSilent | php | browscap/browscap | tests/BrowscapTest/Writer/IniWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/IniWriterTest.php | MIT |
public function testRenderSectionFooterIfSilent(): void
{
$this->object->setSilent(true);
$this->object->renderSectionFooter();
static::assertSame('', file_get_contents($this->file));
} | tests rendering the footer of one section
@throws ExpectationFailedException | testRenderSectionFooterIfSilent | php | browscap/browscap | tests/BrowscapTest/Writer/IniWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/IniWriterTest.php | MIT |
public function testRenderDivisionFooter(): void
{
$this->object->renderDivisionFooter();
static::assertSame('', file_get_contents($this->file));
} | tests rendering the footer of one division
@throws ExpectationFailedException | testRenderDivisionFooter | php | browscap/browscap | tests/BrowscapTest/Writer/IniWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/IniWriterTest.php | MIT |
public function testRenderAllDivisionsFooter(): void
{
$this->object->renderAllDivisionsFooter();
static::assertSame('', file_get_contents($this->file));
} | tests rendering the footer after all divisions
@throws ExpectationFailedException | testRenderAllDivisionsFooter | php | browscap/browscap | tests/BrowscapTest/Writer/IniWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/IniWriterTest.php | MIT |
public function testGetType(): void
{
static::assertSame(WriterInterface::TYPE_JSON, $this->object->getType());
} | tests getting the writer type
@throws ExpectationFailedException | testGetType | php | browscap/browscap | tests/BrowscapTest/Writer/JsonWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/JsonWriterTest.php | MIT |
public function testSetGetFormatter(): void
{
$mockFormatter = $this->createMock(JsonFormatter::class);
$this->object->setFormatter($mockFormatter);
static::assertSame($mockFormatter, $this->object->getFormatter());
} | tests setting and getting a formatter
@throws ExpectationFailedException | testSetGetFormatter | php | browscap/browscap | tests/BrowscapTest/Writer/JsonWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/JsonWriterTest.php | MIT |
public function testSetGetFilter(): void
{
$mockFilter = $this->createMock(StandardFilter::class);
$this->object->setFilter($mockFilter);
static::assertSame($mockFilter, $this->object->getFilter());
} | tests setting and getting a filter
@throws ExpectationFailedException | testSetGetFilter | php | browscap/browscap | tests/BrowscapTest/Writer/JsonWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/JsonWriterTest.php | MIT |
public function testSetGetSilent(): void
{
$this->object->setSilent(true);
static::assertTrue($this->object->isSilent());
} | tests setting a file into silent mode
@throws ExpectationFailedException | testSetGetSilent | php | browscap/browscap | tests/BrowscapTest/Writer/JsonWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/JsonWriterTest.php | MIT |
public function testFileStartIfNotSilent(): void
{
$this->object->setSilent(false);
$this->object->fileStart();
static::assertSame(
'{' . PHP_EOL,
file_get_contents($this->file),
);
} | tests rendering the start of the file
@throws ExpectationFailedException | testFileStartIfNotSilent | php | browscap/browscap | tests/BrowscapTest/Writer/JsonWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/JsonWriterTest.php | MIT |
public function testFileStartIfSilent(): void
{
$this->object->setSilent(true);
$this->object->fileStart();
static::assertSame('', file_get_contents($this->file));
} | tests rendering the start of the file
@throws ExpectationFailedException | testFileStartIfSilent | php | browscap/browscap | tests/BrowscapTest/Writer/JsonWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/JsonWriterTest.php | MIT |
public function testFileEndIfNotSilent(): void
{
$this->object->setSilent(false);
$this->object->fileEnd();
static::assertSame('}' . PHP_EOL, file_get_contents($this->file));
} | tests rendering the end of the file
@throws ExpectationFailedException | testFileEndIfNotSilent | php | browscap/browscap | tests/BrowscapTest/Writer/JsonWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/JsonWriterTest.php | MIT |
public function testFileEndIfSilent(): void
{
$this->object->setSilent(true);
$this->object->fileEnd();
static::assertSame('', file_get_contents($this->file));
} | tests rendering the end of the file
@throws ExpectationFailedException | testFileEndIfSilent | php | browscap/browscap | tests/BrowscapTest/Writer/JsonWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/JsonWriterTest.php | MIT |
public function testRenderHeaderIfSilent(): void
{
$header = ['TestData to be renderd into the Header'];
$this->object->setSilent(true);
$this->object->renderHeader($header);
static::assertSame('', file_get_contents($this->file));
} | tests rendering the header information
@throws ExpectationFailedException
@throws JsonException | testRenderHeaderIfSilent | php | browscap/browscap | tests/BrowscapTest/Writer/JsonWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/JsonWriterTest.php | MIT |
public function testRenderHeaderIfNotSilent(): void
{
$header = ['TestData to be renderd into the Header', 'more data to be rendered', 'much more data'];
$this->object->setSilent(false);
$this->object->renderHeader($header);
static::assertSame(
' "comments": [' . PHP_EOL . ' "TestData to be renderd into the Header",' . PHP_EOL . ' "more data to be rendered",' . PHP_EOL . ' "much more data"' . PHP_EOL . ' ],'
. PHP_EOL,
file_get_contents($this->file),
);
} | tests rendering the header information
@throws ExpectationFailedException
@throws JsonException | testRenderHeaderIfNotSilent | php | browscap/browscap | tests/BrowscapTest/Writer/JsonWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/JsonWriterTest.php | MIT |
public function testRenderVersionIfSilent(): void
{
$version = [
'version' => 'test',
'released' => date('Y-m-d'),
'format' => 'TEST',
'type' => 'full',
];
$this->object->setSilent(true);
$this->object->renderVersion($version);
static::assertSame('', file_get_contents($this->file));
} | tests rendering the version information
@throws ExpectationFailedException
@throws JsonException | testRenderVersionIfSilent | php | browscap/browscap | tests/BrowscapTest/Writer/JsonWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/JsonWriterTest.php | MIT |
public function testRenderVersionIfNotSilent(): void
{
$version = [
'version' => 'test',
'released' => date('Y-m-d'),
'format' => 'TEST',
'type' => 'full',
];
$this->object->setSilent(false);
$this->object->renderVersion($version);
static::assertSame(
' "GJK_Browscap_Version": {' . PHP_EOL . ' "Version": "test",' . PHP_EOL
. ' "Released": "' . date('Y-m-d') . '"' . PHP_EOL . ' },' . PHP_EOL,
file_get_contents($this->file),
);
} | tests rendering the version information
@throws ExpectationFailedException
@throws JsonException | testRenderVersionIfNotSilent | php | browscap/browscap | tests/BrowscapTest/Writer/JsonWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/JsonWriterTest.php | MIT |
public function testRenderVersionIfNotSilentButWithoutVersion(): void
{
$version = [];
$this->object->setSilent(false);
$this->object->renderVersion($version);
static::assertSame(
' "GJK_Browscap_Version": {' . PHP_EOL . ' "Version": "0",' . PHP_EOL
. ' "Released": ""' . PHP_EOL . ' },' . PHP_EOL,
file_get_contents($this->file),
);
} | tests rendering the version information
@throws ExpectationFailedException
@throws JsonException | testRenderVersionIfNotSilentButWithoutVersion | php | browscap/browscap | tests/BrowscapTest/Writer/JsonWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/JsonWriterTest.php | MIT |
public function testRenderAllDivisionsHeader(): void
{
$collection = $this->createMock(DataCollection::class);
assert($collection instanceof DataCollection);
$this->object->renderAllDivisionsHeader($collection);
static::assertSame('', file_get_contents($this->file));
} | tests rendering the header for all division
@throws ExpectationFailedException | testRenderAllDivisionsHeader | php | browscap/browscap | tests/BrowscapTest/Writer/JsonWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/JsonWriterTest.php | MIT |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.