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 renderSectionHeader(string $sectionName): void
{
foreach ($this->writers as $writer) {
$writer->renderSectionHeader($sectionName);
}
} | renders the header for a section
@throws void | renderSectionHeader | php | browscap/browscap | src/Browscap/Writer/WriterCollection.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Writer/WriterCollection.php | MIT |
public function renderSectionBody(array $section, DataCollection $collection, array $sections = [], string $sectionName = ''): void
{
foreach ($this->writers as $writer) {
$writer->renderSectionBody($section, $collection, $sections, $sectionName);
}
} | renders all found useragents into a string
@param array<string, int|string|true> $section
@param array<string, array<string, bool|string>> $sections
@throws InvalidArgumentException | renderSectionBody | php | browscap/browscap | src/Browscap/Writer/WriterCollection.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Writer/WriterCollection.php | MIT |
public function renderSectionFooter(string $sectionName = ''): void
{
foreach ($this->writers as $writer) {
$writer->renderSectionFooter($sectionName);
}
} | renders the footer for a section
@throws void | renderSectionFooter | php | browscap/browscap | src/Browscap/Writer/WriterCollection.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Writer/WriterCollection.php | MIT |
public function renderDivisionFooter(): void
{
foreach ($this->writers as $writer) {
$writer->renderDivisionFooter();
}
} | renders the footer for a division
@throws void | renderDivisionFooter | php | browscap/browscap | src/Browscap/Writer/WriterCollection.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Writer/WriterCollection.php | MIT |
public function renderAllDivisionsFooter(): void
{
foreach ($this->writers as $writer) {
$writer->renderAllDivisionsFooter();
}
} | renders the footer for all divisions
@throws void | renderAllDivisionsFooter | php | browscap/browscap | src/Browscap/Writer/WriterCollection.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Writer/WriterCollection.php | MIT |
public function getType(): string
{
return WriterInterface::TYPE_XML;
} | returns the Type of the writer
@throws void | getType | php | browscap/browscap | src/Browscap/Writer/XmlWriter.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Writer/XmlWriter.php | MIT |
public function close(): void
{
fclose($this->file);
} | closes the Writer and the written File
@throws void | close | php | browscap/browscap | src/Browscap/Writer/XmlWriter.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Writer/XmlWriter.php | MIT |
public function fileStart(): void
{
if ($this->isSilent()) {
return;
}
fwrite($this->file, '<?xml version="1.0" encoding="UTF-8"?>' . PHP_EOL);
fwrite($this->file, '<browsercaps>' . PHP_EOL);
} | Generates a start sequence for the output file
@throws void | fileStart | php | browscap/browscap | src/Browscap/Writer/XmlWriter.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Writer/XmlWriter.php | MIT |
public function fileEnd(): void
{
if ($this->isSilent()) {
return;
}
fwrite($this->file, '</browsercaps>' . PHP_EOL);
} | Generates a end sequence for the output file
@throws void | fileEnd | php | browscap/browscap | src/Browscap/Writer/XmlWriter.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Writer/XmlWriter.php | MIT |
public function renderHeader(array $comments = []): void
{
if ($this->isSilent()) {
return;
}
$this->logger->debug('rendering comments');
fwrite($this->file, '<comments>' . PHP_EOL);
foreach ($comments as $text) {
fwrite($this->file, '<comment><![CDATA[' . $text . ']]></comment>' . PHP_EOL);
}
fwrite($this->file, '</comments>' . PHP_EOL);
} | Generate the header
@param array<string> $comments
@throws void | renderHeader | php | browscap/browscap | src/Browscap/Writer/XmlWriter.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Writer/XmlWriter.php | MIT |
public function renderVersion(array $versionData = []): void
{
if ($this->isSilent()) {
return;
}
$this->logger->debug('rendering version information');
fwrite($this->file, '<gjk_browscap_version>' . PHP_EOL);
if (! isset($versionData['version'])) {
$versionData['version'] = '0';
}
if (! isset($versionData['released'])) {
$versionData['released'] = '';
}
fwrite($this->file, '<item name="Version" value="' . $this->formatter->formatPropertyName($versionData['version']) . '"/>' . PHP_EOL);
fwrite($this->file, '<item name="Released" value="' . $this->formatter->formatPropertyName($versionData['released']) . '"/>' . PHP_EOL);
fwrite($this->file, '</gjk_browscap_version>' . PHP_EOL);
} | renders the version information
@param array<string> $versionData
@throws JsonException | renderVersion | php | browscap/browscap | src/Browscap/Writer/XmlWriter.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Writer/XmlWriter.php | MIT |
public function renderAllDivisionsHeader(DataCollection $collection): void
{
fwrite($this->file, '<browsercapitems>' . PHP_EOL);
} | renders the header for all divisions
@throws void | renderAllDivisionsHeader | php | browscap/browscap | src/Browscap/Writer/XmlWriter.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Writer/XmlWriter.php | MIT |
public function renderDivisionHeader(string $division, string $parent = 'DefaultProperties'): void
{
// nothing to do here
} | renders the header for a division
@throws void | renderDivisionHeader | php | browscap/browscap | src/Browscap/Writer/XmlWriter.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Writer/XmlWriter.php | MIT |
public function renderSectionHeader(string $sectionName): void
{
if ($this->isSilent()) {
return;
}
fwrite(
$this->file,
'<browscapitem name="' . $this->formatter->formatPropertyName($sectionName) . '">' . PHP_EOL,
);
} | renders the header for a section
@throws JsonException | renderSectionHeader | php | browscap/browscap | src/Browscap/Writer/XmlWriter.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Writer/XmlWriter.php | MIT |
public function renderSectionBody(array $section, DataCollection $collection, array $sections = [], string $sectionName = ''): void
{
if ($this->isSilent()) {
return;
}
$division = $collection->getDefaultProperties();
$ua = $division->getUserAgents()[0];
$defaultproperties = $ua->getProperties();
$properties = array_merge(['Parent'], array_keys($defaultproperties));
foreach ($properties as $property) {
if (! isset($section[$property])) {
continue;
}
if (! isset($this->outputProperties[$property])) {
$this->outputProperties[$property] = $this->filter->isOutputProperty($property, $this);
}
if (! $this->outputProperties[$property]) {
continue;
}
fwrite(
$this->file,
'<item name="' . $this->formatter->formatPropertyName($property)
. '" value="' . $this->formatter->formatPropertyValue($section[$property], $property)
. '"/>' . PHP_EOL,
);
}
} | renders all found useragents into a string
@param array<string, int|string|true> $section
@param array<string, array<string, bool|string>> $sections
@throws InvalidArgumentException
@throws Exception
@throws JsonException | renderSectionBody | php | browscap/browscap | src/Browscap/Writer/XmlWriter.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Writer/XmlWriter.php | MIT |
public function renderSectionFooter(string $sectionName = ''): void
{
if ($this->isSilent()) {
return;
}
fwrite($this->file, '</browscapitem>' . PHP_EOL);
} | renders the footer for a section
@throws void | renderSectionFooter | php | browscap/browscap | src/Browscap/Writer/XmlWriter.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Writer/XmlWriter.php | MIT |
public function renderDivisionFooter(): void
{
// nothing to do here
} | renders the footer for a division
@throws void | renderDivisionFooter | php | browscap/browscap | src/Browscap/Writer/XmlWriter.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Writer/XmlWriter.php | MIT |
public function renderAllDivisionsFooter(): void
{
fwrite($this->file, '</browsercapitems>' . PHP_EOL);
} | renders the footer for all divisions
@throws void | renderAllDivisionsFooter | php | browscap/browscap | src/Browscap/Writer/XmlWriter.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Writer/XmlWriter.php | MIT |
public function createCollection(
LoggerInterface $logger,
string $buildFolder,
string|null $file = null,
array $fields = [],
string $format = FormatterInterface::TYPE_PHP,
): WriterCollection {
$writerCollection = new WriterCollection();
$propertyHolder = new PropertyHolder();
if ($file === null) {
switch ($format) {
case FormatterInterface::TYPE_ASP:
$file = $buildFolder . '/full_browscap.ini';
break;
case FormatterInterface::TYPE_CSV:
$file = $buildFolder . '/browscap.csv';
break;
case FormatterInterface::TYPE_XML:
$file = $buildFolder . '/browscap.xml';
break;
case FormatterInterface::TYPE_JSON:
$file = $buildFolder . '/browscap.json';
break;
case FormatterInterface::TYPE_PHP:
default:
$file = $buildFolder . '/full_php_browscap.ini';
break;
}
}
$filter = new CustomFilter($propertyHolder, $fields);
switch ($format) {
case FormatterInterface::TYPE_ASP:
$writer = new Writer\IniWriter($file, $logger);
$formatter = new Formatter\AspFormatter($propertyHolder);
break;
case FormatterInterface::TYPE_CSV:
$writer = new Writer\CsvWriter($file, $logger);
$formatter = new Formatter\CsvFormatter($propertyHolder);
break;
case FormatterInterface::TYPE_XML:
$writer = new Writer\XmlWriter($file, $logger);
$formatter = new Formatter\XmlFormatter($propertyHolder);
break;
case FormatterInterface::TYPE_JSON:
$writer = new Writer\JsonWriter($file, $logger);
$formatter = new Formatter\JsonFormatter($propertyHolder);
break;
case FormatterInterface::TYPE_PHP:
default:
$writer = new Writer\IniWriter($file, $logger);
$formatter = new Formatter\PhpFormatter($propertyHolder);
break;
}
$writer->setFormatter($formatter);
$writer->setFilter($filter);
$writerCollection->addWriter($writer);
return $writerCollection;
} | @param array<string> $fields
@throws InvalidArgumentException | createCollection | php | browscap/browscap | src/Browscap/Writer/Factory/CustomWriterFactory.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Writer/Factory/CustomWriterFactory.php | MIT |
public function testConstructorAddsExpectedCommands(): void
{
$app = new Browscap();
self::assertAppHasCommand($app, 'build');
} | tests adding commands
@throws LogicException
@throws CommandNotFoundException
@group sourcetest | testConstructorAddsExpectedCommands | php | browscap/browscap | tests/BrowscapTest/BrowscapTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/BrowscapTest.php | MIT |
public function testExecuteWithWongLoggerHelper(): void
{
$input = $this->getMockBuilder(InputInterface::class)
->getMock();
$input->expects(self::never())
->method('getOption');
$output = $this->getMockBuilder(OutputInterface::class)
->getMock();
$output->expects(self::never())
->method('writeln');
$validateHelper = $this->createMock(ValidateHelper::class);
$helperSet = $this->getMockBuilder(HelperSet::class)
->getMock();
$helperSet->expects(self::once())
->method('get')
->with('logger')
->willReturn($validateHelper);
$object = new RewriteBrowsersCommand();
$object->setHelperSet($helperSet);
$function = new ReflectionMethod($object, 'execute');
$this->expectException(AssertionError::class);
$this->expectExceptionCode(1);
$this->expectExceptionMessage('assert($loggerHelper instanceof LoggerHelper)');
$function->invoke($object, $input, $output);
} | @throws ExpectationFailedException
@throws ReflectionException
@throws LogicException | testExecuteWithWongLoggerHelper | php | browscap/browscap | tests/BrowscapTest/Command/RewriteBrowsersCommandTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Command/RewriteBrowsersCommandTest.php | MIT |
public function testExecuteWithoutResourcesOption(): void
{
$input = $this->getMockBuilder(InputInterface::class)
->getMock();
$input->expects(self::once())
->method('getOption')
->with('resources')
->willReturn(null);
$output = $this->getMockBuilder(OutputInterface::class)
->getMock();
$output->expects(self::never())
->method('writeln');
$logger = $this->getMockBuilder(LoggerInterface::class)
->getMock();
$logger->expects(self::never())
->method('emergency');
$logger->expects(self::never())
->method('alert');
$logger->expects(self::never())
->method('critical');
$logger->expects(self::never())
->method('error');
$logger->expects(self::never())
->method('warning');
$logger->expects(self::never())
->method('notice');
$logger->expects(self::never())
->method('info');
$logger->expects(self::never())
->method('debug');
$logger->expects(self::never())
->method('log');
$loggerHelper = $this->getMockBuilder(LoggerHelper::class)
->getMock();
$loggerHelper->expects(self::once())
->method('create')
->with($output)
->willReturn($logger);
$helperSet = $this->getMockBuilder(HelperSet::class)
->getMock();
$helperSet->expects(self::once())
->method('get')
->with('logger')
->willReturn($loggerHelper);
$object = new RewriteBrowsersCommand();
$object->setHelperSet($helperSet);
$function = new ReflectionMethod($object, 'execute');
$this->expectException(AssertionError::class);
$this->expectExceptionCode(1);
$this->expectExceptionMessage('assert(is_string($resources))');
$function->invoke($object, $input, $output);
} | @throws ExpectationFailedException
@throws ReflectionException
@throws LogicException | testExecuteWithoutResourcesOption | php | browscap/browscap | tests/BrowscapTest/Command/RewriteBrowsersCommandTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Command/RewriteBrowsersCommandTest.php | MIT |
public function testExecuteWithWongRewriteHelper(): void
{
$resources = 'test-resources';
$input = $this->getMockBuilder(InputInterface::class)
->getMock();
$input->expects(self::once())
->method('getOption')
->with('resources')
->willReturn($resources);
$output = $this->getMockBuilder(OutputInterface::class)
->getMock();
$output->expects(self::never())
->method('writeln');
$logger = $this->getMockBuilder(LoggerInterface::class)
->getMock();
$logger->expects(self::never())
->method('emergency');
$logger->expects(self::never())
->method('alert');
$logger->expects(self::never())
->method('critical');
$logger->expects(self::never())
->method('error');
$logger->expects(self::never())
->method('warning');
$logger->expects(self::never())
->method('notice');
$logger->expects(self::once())
->method('info')
->with(sprintf('Resource folder: %s', $resources));
$logger->expects(self::never())
->method('debug');
$logger->expects(self::never())
->method('log');
$validateHelper = $this->createMock(ValidateHelper::class);
$loggerHelper = $this->getMockBuilder(LoggerHelper::class)
->getMock();
$loggerHelper->expects(self::once())
->method('create')
->with($output)
->willReturn($logger);
$helperSet = $this->getMockBuilder(HelperSet::class)
->getMock();
$helperSet->expects(self::exactly(2))
->method('get')
->willReturnMap(
[
['logger', $loggerHelper],
['rewrite', $validateHelper],
],
);
$object = new RewriteBrowsersCommand();
$object->setHelperSet($helperSet);
$function = new ReflectionMethod($object, 'execute');
$this->expectException(AssertionError::class);
$this->expectExceptionCode(1);
$this->expectExceptionMessage('assert($rewriteHelper instanceof RewriteHelper)');
$function->invoke($object, $input, $output);
} | @throws ExpectationFailedException
@throws ReflectionException
@throws LogicException | testExecuteWithWongRewriteHelper | php | browscap/browscap | tests/BrowscapTest/Command/RewriteBrowsersCommandTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Command/RewriteBrowsersCommandTest.php | MIT |
public function testExecute(): void
{
$resources = 'test-resources';
$schema = 'file://' . realpath(__DIR__ . '/../../../schema/browsers.json');
$input = $this->getMockBuilder(InputInterface::class)
->getMock();
$input->expects(self::once())
->method('getOption')
->with('resources')
->willReturn($resources);
$output = $this->getMockBuilder(OutputInterface::class)
->getMock();
$output->expects(self::once())
->method('writeln')
->with('Done', 0);
$logger = $this->getMockBuilder(LoggerInterface::class)
->getMock();
$logger->expects(self::never())
->method('emergency');
$logger->expects(self::never())
->method('alert');
$logger->expects(self::never())
->method('critical');
$logger->expects(self::never())
->method('error');
$logger->expects(self::never())
->method('warning');
$logger->expects(self::never())
->method('notice');
$logger->expects(self::once())
->method('info')
->with(sprintf('Resource folder: %s', $resources));
$logger->expects(self::never())
->method('debug');
$logger->expects(self::never())
->method('log');
$loggerHelper = $this->getMockBuilder(LoggerHelper::class)
->getMock();
$loggerHelper->expects(self::once())
->method('create')
->with($output)
->willReturn($logger);
$rewriteHelper = $this->getMockBuilder(RewriteHelper::class)
->getMock();
$rewriteHelper->expects(self::once())
->method('rewrite')
->with($logger, $resources . '/browsers', $schema, true);
$helperSet = $this->getMockBuilder(HelperSet::class)
->getMock();
$helperSet->expects(self::exactly(2))
->method('get')
->willReturnMap(
[
['logger', $loggerHelper],
['rewrite', $rewriteHelper],
],
);
$object = new RewriteBrowsersCommand();
$object->setHelperSet($helperSet);
$function = new ReflectionMethod($object, 'execute');
self::assertSame(Command::SUCCESS, $function->invoke($object, $input, $output));
} | @throws ExpectationFailedException
@throws ReflectionException
@throws LogicException | testExecute | php | browscap/browscap | tests/BrowscapTest/Command/RewriteBrowsersCommandTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Command/RewriteBrowsersCommandTest.php | MIT |
public function testExecuteWithWongLoggerHelper(): void
{
$input = $this->getMockBuilder(InputInterface::class)
->getMock();
$input->expects(self::never())
->method('getOption');
$output = $this->getMockBuilder(OutputInterface::class)
->getMock();
$output->expects(self::never())
->method('writeln');
$validateHelper = $this->createMock(ValidateHelper::class);
$helperSet = $this->getMockBuilder(HelperSet::class)
->getMock();
$helperSet->expects(self::once())
->method('get')
->with('logger')
->willReturn($validateHelper);
$object = new RewriteCoreDivisionsCommand();
$object->setHelperSet($helperSet);
$function = new ReflectionMethod($object, 'execute');
$this->expectException(AssertionError::class);
$this->expectExceptionCode(1);
$this->expectExceptionMessage('assert($loggerHelper instanceof LoggerHelper)');
$function->invoke($object, $input, $output);
} | @throws ExpectationFailedException
@throws ReflectionException
@throws LogicException | testExecuteWithWongLoggerHelper | php | browscap/browscap | tests/BrowscapTest/Command/RewriteCoreDivisionsCommandTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Command/RewriteCoreDivisionsCommandTest.php | MIT |
public function testExecuteWithoutResourcesOption(): void
{
$input = $this->getMockBuilder(InputInterface::class)
->getMock();
$input->expects(self::once())
->method('getOption')
->with('resources')
->willReturn(null);
$output = $this->getMockBuilder(OutputInterface::class)
->getMock();
$output->expects(self::never())
->method('writeln');
$logger = $this->getMockBuilder(LoggerInterface::class)
->getMock();
$logger->expects(self::never())
->method('emergency');
$logger->expects(self::never())
->method('alert');
$logger->expects(self::never())
->method('critical');
$logger->expects(self::never())
->method('error');
$logger->expects(self::never())
->method('warning');
$logger->expects(self::never())
->method('notice');
$logger->expects(self::never())
->method('info');
$logger->expects(self::never())
->method('debug');
$logger->expects(self::never())
->method('log');
$loggerHelper = $this->getMockBuilder(LoggerHelper::class)
->getMock();
$loggerHelper->expects(self::once())
->method('create')
->with($output)
->willReturn($logger);
$helperSet = $this->getMockBuilder(HelperSet::class)
->getMock();
$helperSet->expects(self::once())
->method('get')
->with('logger')
->willReturn($loggerHelper);
$object = new RewriteCoreDivisionsCommand();
$object->setHelperSet($helperSet);
$function = new ReflectionMethod($object, 'execute');
$this->expectException(AssertionError::class);
$this->expectExceptionCode(1);
$this->expectExceptionMessage('assert(is_string($resources))');
$function->invoke($object, $input, $output);
} | @throws ExpectationFailedException
@throws ReflectionException
@throws LogicException | testExecuteWithoutResourcesOption | php | browscap/browscap | tests/BrowscapTest/Command/RewriteCoreDivisionsCommandTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Command/RewriteCoreDivisionsCommandTest.php | MIT |
public function testExecuteWithWongRewriteHelper(): void
{
$resources = 'test-resources';
$input = $this->getMockBuilder(InputInterface::class)
->getMock();
$input->expects(self::once())
->method('getOption')
->with('resources')
->willReturn($resources);
$output = $this->getMockBuilder(OutputInterface::class)
->getMock();
$output->expects(self::never())
->method('writeln');
$logger = $this->getMockBuilder(LoggerInterface::class)
->getMock();
$logger->expects(self::never())
->method('emergency');
$logger->expects(self::never())
->method('alert');
$logger->expects(self::never())
->method('critical');
$logger->expects(self::never())
->method('error');
$logger->expects(self::never())
->method('warning');
$logger->expects(self::never())
->method('notice');
$logger->expects(self::once())
->method('info')
->with(sprintf('Resource folder: %s', $resources));
$logger->expects(self::never())
->method('debug');
$logger->expects(self::never())
->method('log');
$validateHelper = $this->createMock(ValidateHelper::class);
$loggerHelper = $this->getMockBuilder(LoggerHelper::class)
->getMock();
$loggerHelper->expects(self::once())
->method('create')
->with($output)
->willReturn($logger);
$helperSet = $this->getMockBuilder(HelperSet::class)
->getMock();
$helperSet->expects(self::exactly(2))
->method('get')
->willReturnMap(
[
['logger', $loggerHelper],
['rewrite', $validateHelper],
],
);
$object = new RewriteCoreDivisionsCommand();
$object->setHelperSet($helperSet);
$function = new ReflectionMethod($object, 'execute');
$this->expectException(AssertionError::class);
$this->expectExceptionCode(1);
$this->expectExceptionMessage('assert($rewriteHelper instanceof RewriteHelper)');
$function->invoke($object, $input, $output);
} | @throws ExpectationFailedException
@throws ReflectionException
@throws LogicException | testExecuteWithWongRewriteHelper | php | browscap/browscap | tests/BrowscapTest/Command/RewriteCoreDivisionsCommandTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Command/RewriteCoreDivisionsCommandTest.php | MIT |
public function testExecute(): void
{
$resources = 'test-resources';
$schema = 'file://' . realpath(__DIR__ . '/../../../schema/core-divisions.json');
$input = $this->getMockBuilder(InputInterface::class)
->getMock();
$input->expects(self::once())
->method('getOption')
->with('resources')
->willReturn($resources);
$output = $this->getMockBuilder(OutputInterface::class)
->getMock();
$output->expects(self::once())
->method('writeln')
->with('Done', 0);
$logger = $this->getMockBuilder(LoggerInterface::class)
->getMock();
$logger->expects(self::never())
->method('emergency');
$logger->expects(self::never())
->method('alert');
$logger->expects(self::never())
->method('critical');
$logger->expects(self::never())
->method('error');
$logger->expects(self::never())
->method('warning');
$logger->expects(self::never())
->method('notice');
$logger->expects(self::once())
->method('info')
->with(sprintf('Resource folder: %s', $resources));
$logger->expects(self::never())
->method('debug');
$logger->expects(self::never())
->method('log');
$loggerHelper = $this->getMockBuilder(LoggerHelper::class)
->getMock();
$loggerHelper->expects(self::once())
->method('create')
->with($output)
->willReturn($logger);
$rewriteHelper = $this->getMockBuilder(RewriteHelper::class)
->getMock();
$rewriteHelper->expects(self::once())
->method('rewrite')
->with($logger, $resources . '/core', $schema, false);
$helperSet = $this->getMockBuilder(HelperSet::class)
->getMock();
$helperSet->expects(self::exactly(2))
->method('get')
->willReturnMap(
[
['logger', $loggerHelper],
['rewrite', $rewriteHelper],
],
);
$object = new RewriteCoreDivisionsCommand();
$object->setHelperSet($helperSet);
$function = new ReflectionMethod($object, 'execute');
self::assertSame(Command::SUCCESS, $function->invoke($object, $input, $output));
} | @throws ExpectationFailedException
@throws ReflectionException
@throws LogicException | testExecute | php | browscap/browscap | tests/BrowscapTest/Command/RewriteCoreDivisionsCommandTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Command/RewriteCoreDivisionsCommandTest.php | MIT |
public function testExecuteWithWongLoggerHelper(): void
{
$input = $this->getMockBuilder(InputInterface::class)
->getMock();
$input->expects(self::never())
->method('getOption');
$output = $this->getMockBuilder(OutputInterface::class)
->getMock();
$output->expects(self::never())
->method('writeln');
$validateHelper = $this->createMock(ValidateHelper::class);
$helperSet = $this->getMockBuilder(HelperSet::class)
->getMock();
$helperSet->expects(self::once())
->method('get')
->with('logger')
->willReturn($validateHelper);
$object = new RewriteDevicesCommand();
$object->setHelperSet($helperSet);
$function = new ReflectionMethod($object, 'execute');
$this->expectException(AssertionError::class);
$this->expectExceptionCode(1);
$this->expectExceptionMessage('assert($loggerHelper instanceof LoggerHelper)');
$function->invoke($object, $input, $output);
} | @throws ExpectationFailedException
@throws ReflectionException
@throws LogicException | testExecuteWithWongLoggerHelper | php | browscap/browscap | tests/BrowscapTest/Command/RewriteDevicesCommandTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Command/RewriteDevicesCommandTest.php | MIT |
public function testExecuteWithoutResourcesOption(): void
{
$input = $this->getMockBuilder(InputInterface::class)
->getMock();
$input->expects(self::once())
->method('getOption')
->with('resources')
->willReturn(null);
$output = $this->getMockBuilder(OutputInterface::class)
->getMock();
$output->expects(self::never())
->method('writeln');
$logger = $this->getMockBuilder(LoggerInterface::class)
->getMock();
$logger->expects(self::never())
->method('emergency');
$logger->expects(self::never())
->method('alert');
$logger->expects(self::never())
->method('critical');
$logger->expects(self::never())
->method('error');
$logger->expects(self::never())
->method('warning');
$logger->expects(self::never())
->method('notice');
$logger->expects(self::never())
->method('info');
$logger->expects(self::never())
->method('debug');
$logger->expects(self::never())
->method('log');
$loggerHelper = $this->getMockBuilder(LoggerHelper::class)
->getMock();
$loggerHelper->expects(self::once())
->method('create')
->with($output)
->willReturn($logger);
$helperSet = $this->getMockBuilder(HelperSet::class)
->getMock();
$helperSet->expects(self::once())
->method('get')
->with('logger')
->willReturn($loggerHelper);
$object = new RewriteDevicesCommand();
$object->setHelperSet($helperSet);
$function = new ReflectionMethod($object, 'execute');
$this->expectException(AssertionError::class);
$this->expectExceptionCode(1);
$this->expectExceptionMessage('assert(is_string($resources))');
$function->invoke($object, $input, $output);
} | @throws ExpectationFailedException
@throws ReflectionException
@throws LogicException | testExecuteWithoutResourcesOption | php | browscap/browscap | tests/BrowscapTest/Command/RewriteDevicesCommandTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Command/RewriteDevicesCommandTest.php | MIT |
public function testExecuteWithWongRewriteHelper(): void
{
$resources = 'test-resources';
$input = $this->getMockBuilder(InputInterface::class)
->getMock();
$input->expects(self::once())
->method('getOption')
->with('resources')
->willReturn($resources);
$output = $this->getMockBuilder(OutputInterface::class)
->getMock();
$output->expects(self::never())
->method('writeln');
$logger = $this->getMockBuilder(LoggerInterface::class)
->getMock();
$logger->expects(self::never())
->method('emergency');
$logger->expects(self::never())
->method('alert');
$logger->expects(self::never())
->method('critical');
$logger->expects(self::never())
->method('error');
$logger->expects(self::never())
->method('warning');
$logger->expects(self::never())
->method('notice');
$logger->expects(self::once())
->method('info')
->with(sprintf('Resource folder: %s', $resources));
$logger->expects(self::never())
->method('debug');
$logger->expects(self::never())
->method('log');
$validateHelper = $this->createMock(ValidateHelper::class);
$loggerHelper = $this->getMockBuilder(LoggerHelper::class)
->getMock();
$loggerHelper->expects(self::once())
->method('create')
->with($output)
->willReturn($logger);
$helperSet = $this->getMockBuilder(HelperSet::class)
->getMock();
$helperSet->expects(self::exactly(2))
->method('get')
->willReturnMap(
[
['logger', $loggerHelper],
['rewrite', $validateHelper],
],
);
$object = new RewriteDevicesCommand();
$object->setHelperSet($helperSet);
$function = new ReflectionMethod($object, 'execute');
$this->expectException(AssertionError::class);
$this->expectExceptionCode(1);
$this->expectExceptionMessage('assert($rewriteHelper instanceof RewriteHelper)');
$function->invoke($object, $input, $output);
} | @throws ExpectationFailedException
@throws ReflectionException
@throws LogicException | testExecuteWithWongRewriteHelper | php | browscap/browscap | tests/BrowscapTest/Command/RewriteDevicesCommandTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Command/RewriteDevicesCommandTest.php | MIT |
public function testExecute(): void
{
$resources = 'test-resources';
$schema = 'file://' . realpath(__DIR__ . '/../../../schema/devices.json');
$input = $this->getMockBuilder(InputInterface::class)
->getMock();
$input->expects(self::once())
->method('getOption')
->with('resources')
->willReturn($resources);
$output = $this->getMockBuilder(OutputInterface::class)
->getMock();
$output->expects(self::once())
->method('writeln')
->with('Done', 0);
$logger = $this->getMockBuilder(LoggerInterface::class)
->getMock();
$logger->expects(self::never())
->method('emergency');
$logger->expects(self::never())
->method('alert');
$logger->expects(self::never())
->method('critical');
$logger->expects(self::never())
->method('error');
$logger->expects(self::never())
->method('warning');
$logger->expects(self::never())
->method('notice');
$logger->expects(self::once())
->method('info')
->with(sprintf('Resource folder: %s', $resources));
$logger->expects(self::never())
->method('debug');
$logger->expects(self::never())
->method('log');
$loggerHelper = $this->getMockBuilder(LoggerHelper::class)
->getMock();
$loggerHelper->expects(self::once())
->method('create')
->with($output)
->willReturn($logger);
$rewriteHelper = $this->getMockBuilder(RewriteHelper::class)
->getMock();
$rewriteHelper->expects(self::once())
->method('rewrite')
->with($logger, $resources . '/devices', $schema, true);
$helperSet = $this->getMockBuilder(HelperSet::class)
->getMock();
$helperSet->expects(self::exactly(2))
->method('get')
->willReturnMap(
[
['logger', $loggerHelper],
['rewrite', $rewriteHelper],
],
);
$object = new RewriteDevicesCommand();
$object->setHelperSet($helperSet);
$function = new ReflectionMethod($object, 'execute');
self::assertSame(Command::SUCCESS, $function->invoke($object, $input, $output));
} | @throws ExpectationFailedException
@throws ReflectionException
@throws LogicException | testExecute | php | browscap/browscap | tests/BrowscapTest/Command/RewriteDevicesCommandTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Command/RewriteDevicesCommandTest.php | MIT |
public function testExecuteWithWongLoggerHelper(): void
{
$input = $this->getMockBuilder(InputInterface::class)
->getMock();
$input->expects(self::never())
->method('getOption');
$output = $this->getMockBuilder(OutputInterface::class)
->getMock();
$output->expects(self::never())
->method('writeln');
$validateHelper = $this->createMock(ValidateHelper::class);
$helperSet = $this->getMockBuilder(HelperSet::class)
->getMock();
$helperSet->expects(self::once())
->method('get')
->with('logger')
->willReturn($validateHelper);
$object = new RewriteEnginesCommand();
$object->setHelperSet($helperSet);
$function = new ReflectionMethod($object, 'execute');
$this->expectException(AssertionError::class);
$this->expectExceptionCode(1);
$this->expectExceptionMessage('assert($loggerHelper instanceof LoggerHelper)');
$function->invoke($object, $input, $output);
} | @throws ExpectationFailedException
@throws ReflectionException
@throws LogicException | testExecuteWithWongLoggerHelper | php | browscap/browscap | tests/BrowscapTest/Command/RewriteEnginesCommandTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Command/RewriteEnginesCommandTest.php | MIT |
public function testExecuteWithoutResourcesOption(): void
{
$input = $this->getMockBuilder(InputInterface::class)
->getMock();
$input->expects(self::once())
->method('getOption')
->with('resources')
->willReturn(null);
$output = $this->getMockBuilder(OutputInterface::class)
->getMock();
$output->expects(self::never())
->method('writeln');
$logger = $this->getMockBuilder(LoggerInterface::class)
->getMock();
$logger->expects(self::never())
->method('emergency');
$logger->expects(self::never())
->method('alert');
$logger->expects(self::never())
->method('critical');
$logger->expects(self::never())
->method('error');
$logger->expects(self::never())
->method('warning');
$logger->expects(self::never())
->method('notice');
$logger->expects(self::never())
->method('info');
$logger->expects(self::never())
->method('debug');
$logger->expects(self::never())
->method('log');
$loggerHelper = $this->getMockBuilder(LoggerHelper::class)
->getMock();
$loggerHelper->expects(self::once())
->method('create')
->with($output)
->willReturn($logger);
$helperSet = $this->getMockBuilder(HelperSet::class)
->getMock();
$helperSet->expects(self::once())
->method('get')
->with('logger')
->willReturn($loggerHelper);
$object = new RewriteEnginesCommand();
$object->setHelperSet($helperSet);
$function = new ReflectionMethod($object, 'execute');
$this->expectException(AssertionError::class);
$this->expectExceptionCode(1);
$this->expectExceptionMessage('assert(is_string($resources))');
$function->invoke($object, $input, $output);
} | @throws ExpectationFailedException
@throws ReflectionException
@throws LogicException | testExecuteWithoutResourcesOption | php | browscap/browscap | tests/BrowscapTest/Command/RewriteEnginesCommandTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Command/RewriteEnginesCommandTest.php | MIT |
public function testExecuteWithWongRewriteHelper(): void
{
$resources = 'test-resources';
$input = $this->getMockBuilder(InputInterface::class)
->getMock();
$input->expects(self::once())
->method('getOption')
->with('resources')
->willReturn($resources);
$output = $this->getMockBuilder(OutputInterface::class)
->getMock();
$output->expects(self::never())
->method('writeln');
$logger = $this->getMockBuilder(LoggerInterface::class)
->getMock();
$logger->expects(self::never())
->method('emergency');
$logger->expects(self::never())
->method('alert');
$logger->expects(self::never())
->method('critical');
$logger->expects(self::never())
->method('error');
$logger->expects(self::never())
->method('warning');
$logger->expects(self::never())
->method('notice');
$logger->expects(self::once())
->method('info')
->with(sprintf('Resource folder: %s', $resources));
$logger->expects(self::never())
->method('debug');
$logger->expects(self::never())
->method('log');
$validateHelper = $this->createMock(ValidateHelper::class);
$loggerHelper = $this->getMockBuilder(LoggerHelper::class)
->getMock();
$loggerHelper->expects(self::once())
->method('create')
->with($output)
->willReturn($logger);
$helperSet = $this->getMockBuilder(HelperSet::class)
->getMock();
$helperSet->expects(self::exactly(2))
->method('get')
->willReturnMap(
[
['logger', $loggerHelper],
['rewrite', $validateHelper],
],
);
$object = new RewriteEnginesCommand();
$object->setHelperSet($helperSet);
$function = new ReflectionMethod($object, 'execute');
$this->expectException(AssertionError::class);
$this->expectExceptionCode(1);
$this->expectExceptionMessage('assert($rewriteHelper instanceof RewriteHelper)');
$function->invoke($object, $input, $output);
} | @throws ExpectationFailedException
@throws ReflectionException
@throws LogicException | testExecuteWithWongRewriteHelper | php | browscap/browscap | tests/BrowscapTest/Command/RewriteEnginesCommandTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Command/RewriteEnginesCommandTest.php | MIT |
public function testExecute(): void
{
$resources = 'test-resources';
$schema = 'file://' . realpath(__DIR__ . '/../../../schema/engines.json');
$input = $this->getMockBuilder(InputInterface::class)
->getMock();
$input->expects(self::once())
->method('getOption')
->with('resources')
->willReturn($resources);
$output = $this->getMockBuilder(OutputInterface::class)
->getMock();
$output->expects(self::once())
->method('writeln')
->with('Done', 0);
$logger = $this->getMockBuilder(LoggerInterface::class)
->getMock();
$logger->expects(self::never())
->method('emergency');
$logger->expects(self::never())
->method('alert');
$logger->expects(self::never())
->method('critical');
$logger->expects(self::never())
->method('error');
$logger->expects(self::never())
->method('warning');
$logger->expects(self::never())
->method('notice');
$logger->expects(self::once())
->method('info')
->with(sprintf('Resource folder: %s', $resources));
$logger->expects(self::never())
->method('debug');
$logger->expects(self::never())
->method('log');
$loggerHelper = $this->getMockBuilder(LoggerHelper::class)
->getMock();
$loggerHelper->expects(self::once())
->method('create')
->with($output)
->willReturn($logger);
$rewriteHelper = $this->getMockBuilder(RewriteHelper::class)
->getMock();
$rewriteHelper->expects(self::once())
->method('rewrite')
->with($logger, $resources . '/engines', $schema, true);
$helperSet = $this->getMockBuilder(HelperSet::class)
->getMock();
$helperSet->expects(self::exactly(2))
->method('get')
->willReturnMap(
[
['logger', $loggerHelper],
['rewrite', $rewriteHelper],
],
);
$object = new RewriteEnginesCommand();
$object->setHelperSet($helperSet);
$function = new ReflectionMethod($object, 'execute');
self::assertSame(Command::SUCCESS, $function->invoke($object, $input, $output));
} | @throws ExpectationFailedException
@throws ReflectionException
@throws LogicException | testExecute | php | browscap/browscap | tests/BrowscapTest/Command/RewriteEnginesCommandTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Command/RewriteEnginesCommandTest.php | MIT |
public function testExecuteWithWongLoggerHelper(): void
{
$input = $this->getMockBuilder(InputInterface::class)
->getMock();
$input->expects(self::never())
->method('getOption');
$output = $this->getMockBuilder(OutputInterface::class)
->getMock();
$output->expects(self::never())
->method('writeln');
$validateHelper = $this->createMock(ValidateHelper::class);
$helperSet = $this->getMockBuilder(HelperSet::class)
->getMock();
$helperSet->expects(self::once())
->method('get')
->with('logger')
->willReturn($validateHelper);
$object = new RewritePlatformsCommand();
$object->setHelperSet($helperSet);
$function = new ReflectionMethod($object, 'execute');
$this->expectException(AssertionError::class);
$this->expectExceptionCode(1);
$this->expectExceptionMessage('assert($loggerHelper instanceof LoggerHelper)');
$function->invoke($object, $input, $output);
} | @throws ExpectationFailedException
@throws ReflectionException
@throws LogicException | testExecuteWithWongLoggerHelper | php | browscap/browscap | tests/BrowscapTest/Command/RewritePlatformsCommandTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Command/RewritePlatformsCommandTest.php | MIT |
public function testExecuteWithoutResourcesOption(): void
{
$input = $this->getMockBuilder(InputInterface::class)
->getMock();
$input->expects(self::once())
->method('getOption')
->with('resources')
->willReturn(null);
$output = $this->getMockBuilder(OutputInterface::class)
->getMock();
$output->expects(self::never())
->method('writeln');
$logger = $this->getMockBuilder(LoggerInterface::class)
->getMock();
$logger->expects(self::never())
->method('emergency');
$logger->expects(self::never())
->method('alert');
$logger->expects(self::never())
->method('critical');
$logger->expects(self::never())
->method('error');
$logger->expects(self::never())
->method('warning');
$logger->expects(self::never())
->method('notice');
$logger->expects(self::never())
->method('info');
$logger->expects(self::never())
->method('debug');
$logger->expects(self::never())
->method('log');
$loggerHelper = $this->getMockBuilder(LoggerHelper::class)
->getMock();
$loggerHelper->expects(self::once())
->method('create')
->with($output)
->willReturn($logger);
$helperSet = $this->getMockBuilder(HelperSet::class)
->getMock();
$helperSet->expects(self::once())
->method('get')
->with('logger')
->willReturn($loggerHelper);
$object = new RewritePlatformsCommand();
$object->setHelperSet($helperSet);
$function = new ReflectionMethod($object, 'execute');
$this->expectException(AssertionError::class);
$this->expectExceptionCode(1);
$this->expectExceptionMessage('assert(is_string($resources))');
$function->invoke($object, $input, $output);
} | @throws ExpectationFailedException
@throws ReflectionException
@throws LogicException | testExecuteWithoutResourcesOption | php | browscap/browscap | tests/BrowscapTest/Command/RewritePlatformsCommandTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Command/RewritePlatformsCommandTest.php | MIT |
public function testExecuteWithWongRewriteHelper(): void
{
$resources = 'test-resources';
$input = $this->getMockBuilder(InputInterface::class)
->getMock();
$input->expects(self::once())
->method('getOption')
->with('resources')
->willReturn($resources);
$output = $this->getMockBuilder(OutputInterface::class)
->getMock();
$output->expects(self::never())
->method('writeln');
$logger = $this->getMockBuilder(LoggerInterface::class)
->getMock();
$logger->expects(self::never())
->method('emergency');
$logger->expects(self::never())
->method('alert');
$logger->expects(self::never())
->method('critical');
$logger->expects(self::never())
->method('error');
$logger->expects(self::never())
->method('warning');
$logger->expects(self::never())
->method('notice');
$logger->expects(self::once())
->method('info')
->with(sprintf('Resource folder: %s', $resources));
$logger->expects(self::never())
->method('debug');
$logger->expects(self::never())
->method('log');
$validateHelper = $this->createMock(ValidateHelper::class);
$loggerHelper = $this->getMockBuilder(LoggerHelper::class)
->getMock();
$loggerHelper->expects(self::once())
->method('create')
->with($output)
->willReturn($logger);
$helperSet = $this->getMockBuilder(HelperSet::class)
->getMock();
$helperSet->expects(self::exactly(2))
->method('get')
->willReturnMap(
[
['logger', $loggerHelper],
['rewrite', $validateHelper],
],
);
$object = new RewritePlatformsCommand();
$object->setHelperSet($helperSet);
$function = new ReflectionMethod($object, 'execute');
$this->expectException(AssertionError::class);
$this->expectExceptionCode(1);
$this->expectExceptionMessage('assert($rewriteHelper instanceof RewriteHelper)');
$function->invoke($object, $input, $output);
} | @throws ExpectationFailedException
@throws ReflectionException
@throws LogicException | testExecuteWithWongRewriteHelper | php | browscap/browscap | tests/BrowscapTest/Command/RewritePlatformsCommandTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Command/RewritePlatformsCommandTest.php | MIT |
public function testExecute(): void
{
$resources = 'test-resources';
$schema = 'file://' . realpath(__DIR__ . '/../../../schema/platforms.json');
$input = $this->getMockBuilder(InputInterface::class)
->getMock();
$input->expects(self::once())
->method('getOption')
->with('resources')
->willReturn($resources);
$output = $this->getMockBuilder(OutputInterface::class)
->getMock();
$output->expects(self::once())
->method('writeln')
->with('Done', 0);
$logger = $this->getMockBuilder(LoggerInterface::class)
->getMock();
$logger->expects(self::never())
->method('emergency');
$logger->expects(self::never())
->method('alert');
$logger->expects(self::never())
->method('critical');
$logger->expects(self::never())
->method('error');
$logger->expects(self::never())
->method('warning');
$logger->expects(self::never())
->method('notice');
$logger->expects(self::once())
->method('info')
->with(sprintf('Resource folder: %s', $resources));
$logger->expects(self::never())
->method('debug');
$logger->expects(self::never())
->method('log');
$loggerHelper = $this->getMockBuilder(LoggerHelper::class)
->getMock();
$loggerHelper->expects(self::once())
->method('create')
->with($output)
->willReturn($logger);
$rewriteHelper = $this->getMockBuilder(RewriteHelper::class)
->getMock();
$rewriteHelper->expects(self::once())
->method('rewrite')
->with($logger, $resources . '/platforms', $schema, true);
$helperSet = $this->getMockBuilder(HelperSet::class)
->getMock();
$helperSet->expects(self::exactly(2))
->method('get')
->willReturnMap(
[
['logger', $loggerHelper],
['rewrite', $rewriteHelper],
],
);
$object = new RewritePlatformsCommand();
$object->setHelperSet($helperSet);
$function = new ReflectionMethod($object, 'execute');
self::assertSame(Command::SUCCESS, $function->invoke($object, $input, $output));
} | @throws ExpectationFailedException
@throws ReflectionException
@throws LogicException | testExecute | php | browscap/browscap | tests/BrowscapTest/Command/RewritePlatformsCommandTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Command/RewritePlatformsCommandTest.php | MIT |
public function testExecuteWithWongLoggerHelper(): void
{
$input = $this->getMockBuilder(InputInterface::class)
->getMock();
$input->expects(self::never())
->method('getOption');
$output = $this->getMockBuilder(OutputInterface::class)
->getMock();
$output->expects(self::never())
->method('writeln');
$validateHelper = $this->createMock(ValidateHelper::class);
$helperSet = $this->getMockBuilder(HelperSet::class)
->getMock();
$helperSet->expects(self::once())
->method('get')
->with('logger')
->willReturn($validateHelper);
$object = new ValidateBrowsersCommand();
$object->setHelperSet($helperSet);
$function = new ReflectionMethod($object, 'execute');
$this->expectException(AssertionError::class);
$this->expectExceptionCode(1);
$this->expectExceptionMessage('assert($loggerHelper instanceof LoggerHelper)');
$function->invoke($object, $input, $output);
} | @throws ExpectationFailedException
@throws ReflectionException
@throws LogicException | testExecuteWithWongLoggerHelper | php | browscap/browscap | tests/BrowscapTest/Command/ValidateBrowsersCommandTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Command/ValidateBrowsersCommandTest.php | MIT |
public function testExecuteWithoutResourcesOption(): void
{
$input = $this->getMockBuilder(InputInterface::class)
->getMock();
$input->expects(self::once())
->method('getOption')
->with('resources')
->willReturn(null);
$output = $this->getMockBuilder(OutputInterface::class)
->getMock();
$output->expects(self::never())
->method('writeln');
$logger = $this->getMockBuilder(LoggerInterface::class)
->getMock();
$logger->expects(self::never())
->method('emergency');
$logger->expects(self::never())
->method('alert');
$logger->expects(self::never())
->method('critical');
$logger->expects(self::never())
->method('error');
$logger->expects(self::never())
->method('warning');
$logger->expects(self::never())
->method('notice');
$logger->expects(self::never())
->method('info');
$logger->expects(self::never())
->method('debug');
$logger->expects(self::never())
->method('log');
$loggerHelper = $this->getMockBuilder(LoggerHelper::class)
->getMock();
$loggerHelper->expects(self::once())
->method('create')
->with($output)
->willReturn($logger);
$helperSet = $this->getMockBuilder(HelperSet::class)
->getMock();
$helperSet->expects(self::once())
->method('get')
->with('logger')
->willReturn($loggerHelper);
$object = new ValidateBrowsersCommand();
$object->setHelperSet($helperSet);
$function = new ReflectionMethod($object, 'execute');
$this->expectException(AssertionError::class);
$this->expectExceptionCode(1);
$this->expectExceptionMessage('assert(is_string($resources))');
$function->invoke($object, $input, $output);
} | @throws ExpectationFailedException
@throws ReflectionException
@throws LogicException | testExecuteWithoutResourcesOption | php | browscap/browscap | tests/BrowscapTest/Command/ValidateBrowsersCommandTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Command/ValidateBrowsersCommandTest.php | MIT |
public function testExecuteWithWongRewriteHelper(): void
{
$resources = 'test-resources';
$input = $this->getMockBuilder(InputInterface::class)
->getMock();
$input->expects(self::once())
->method('getOption')
->with('resources')
->willReturn($resources);
$output = $this->getMockBuilder(OutputInterface::class)
->getMock();
$output->expects(self::never())
->method('writeln');
$logger = $this->getMockBuilder(LoggerInterface::class)
->getMock();
$logger->expects(self::never())
->method('emergency');
$logger->expects(self::never())
->method('alert');
$logger->expects(self::never())
->method('critical');
$logger->expects(self::never())
->method('error');
$logger->expects(self::never())
->method('warning');
$logger->expects(self::never())
->method('notice');
$logger->expects(self::once())
->method('info')
->with(sprintf('Resource folder: %s', $resources));
$logger->expects(self::never())
->method('debug');
$logger->expects(self::never())
->method('log');
$rewriteHelper = $this->createMock(RewriteHelper::class);
$loggerHelper = $this->getMockBuilder(LoggerHelper::class)
->getMock();
$loggerHelper->expects(self::once())
->method('create')
->with($output)
->willReturn($logger);
$helperSet = $this->getMockBuilder(HelperSet::class)
->getMock();
$helperSet->expects(self::exactly(2))
->method('get')
->willReturnMap(
[
['logger', $loggerHelper],
['validate', $rewriteHelper],
],
);
$object = new ValidateBrowsersCommand();
$object->setHelperSet($helperSet);
$function = new ReflectionMethod($object, 'execute');
$this->expectException(AssertionError::class);
$this->expectExceptionCode(1);
$this->expectExceptionMessage('assert($validateHelper instanceof ValidateHelper)');
$function->invoke($object, $input, $output);
} | @throws ExpectationFailedException
@throws ReflectionException
@throws LogicException | testExecuteWithWongRewriteHelper | php | browscap/browscap | tests/BrowscapTest/Command/ValidateBrowsersCommandTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Command/ValidateBrowsersCommandTest.php | MIT |
public function testExecuteValidationFailed(): void
{
$resources = 'test-resources';
$schema = 'file://' . realpath(__DIR__ . '/../../../schema/browsers.json');
$input = $this->getMockBuilder(InputInterface::class)
->getMock();
$input->expects(self::once())
->method('getOption')
->with('resources')
->willReturn($resources);
$output = $this->getMockBuilder(OutputInterface::class)
->getMock();
$output->expects(self::once())
->method('writeln')
->with('<fg=red>invalid</>', 0);
$logger = $this->getMockBuilder(LoggerInterface::class)
->getMock();
$logger->expects(self::never())
->method('emergency');
$logger->expects(self::never())
->method('alert');
$logger->expects(self::never())
->method('critical');
$logger->expects(self::never())
->method('error');
$logger->expects(self::never())
->method('warning');
$logger->expects(self::never())
->method('notice');
$logger->expects(self::once())
->method('info')
->with(sprintf('Resource folder: %s', $resources));
$logger->expects(self::never())
->method('debug');
$logger->expects(self::never())
->method('log');
$loggerHelper = $this->getMockBuilder(LoggerHelper::class)
->getMock();
$loggerHelper->expects(self::once())
->method('create')
->with($output)
->willReturn($logger);
$validateHelper = $this->getMockBuilder(ValidateHelper::class)
->getMock();
$validateHelper->expects(self::once())
->method('validate')
->with($logger, $resources . '/browsers', $schema)
->willReturn(true);
$helperSet = $this->getMockBuilder(HelperSet::class)
->getMock();
$helperSet->expects(self::exactly(2))
->method('get')
->willReturnMap(
[
['logger', $loggerHelper],
['validate', $validateHelper],
],
);
$object = new ValidateBrowsersCommand();
$object->setHelperSet($helperSet);
$function = new ReflectionMethod($object, 'execute');
self::assertSame(Command::FAILURE, $function->invoke($object, $input, $output));
} | @throws ExpectationFailedException
@throws ReflectionException
@throws LogicException | testExecuteValidationFailed | php | browscap/browscap | tests/BrowscapTest/Command/ValidateBrowsersCommandTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Command/ValidateBrowsersCommandTest.php | MIT |
public function testExecuteValidationSuccess(): void
{
$resources = 'test-resources';
$schema = 'file://' . realpath(__DIR__ . '/../../../schema/browsers.json');
$input = $this->getMockBuilder(InputInterface::class)
->getMock();
$input->expects(self::once())
->method('getOption')
->with('resources')
->willReturn($resources);
$output = $this->getMockBuilder(OutputInterface::class)
->getMock();
$output->expects(self::once())
->method('writeln')
->with('<fg=green>valid</>', 0);
$logger = $this->getMockBuilder(LoggerInterface::class)
->getMock();
$logger->expects(self::never())
->method('emergency');
$logger->expects(self::never())
->method('alert');
$logger->expects(self::never())
->method('critical');
$logger->expects(self::never())
->method('error');
$logger->expects(self::never())
->method('warning');
$logger->expects(self::never())
->method('notice');
$logger->expects(self::once())
->method('info')
->with(sprintf('Resource folder: %s', $resources));
$logger->expects(self::never())
->method('debug');
$logger->expects(self::never())
->method('log');
$loggerHelper = $this->getMockBuilder(LoggerHelper::class)
->getMock();
$loggerHelper->expects(self::once())
->method('create')
->with($output)
->willReturn($logger);
$validateHelper = $this->getMockBuilder(ValidateHelper::class)
->getMock();
$validateHelper->expects(self::once())
->method('validate')
->with($logger, $resources . '/browsers', $schema)
->willReturn(false);
$helperSet = $this->getMockBuilder(HelperSet::class)
->getMock();
$helperSet->expects(self::exactly(2))
->method('get')
->willReturnMap(
[
['logger', $loggerHelper],
['validate', $validateHelper],
],
);
$object = new ValidateBrowsersCommand();
$object->setHelperSet($helperSet);
$function = new ReflectionMethod($object, 'execute');
self::assertSame(Command::SUCCESS, $function->invoke($object, $input, $output));
} | @throws ExpectationFailedException
@throws ReflectionException
@throws LogicException | testExecuteValidationSuccess | php | browscap/browscap | tests/BrowscapTest/Command/ValidateBrowsersCommandTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Command/ValidateBrowsersCommandTest.php | MIT |
public function testExecuteWithWongLoggerHelper(): void
{
$input = $this->getMockBuilder(InputInterface::class)
->getMock();
$input->expects(self::never())
->method('getOption');
$output = $this->getMockBuilder(OutputInterface::class)
->getMock();
$output->expects(self::never())
->method('writeln');
$validateHelper = $this->createMock(ValidateHelper::class);
$helperSet = $this->getMockBuilder(HelperSet::class)
->getMock();
$helperSet->expects(self::once())
->method('get')
->with('logger')
->willReturn($validateHelper);
$object = new ValidateCoreDivisionsCommand();
$object->setHelperSet($helperSet);
$function = new ReflectionMethod($object, 'execute');
$this->expectException(AssertionError::class);
$this->expectExceptionCode(1);
$this->expectExceptionMessage('assert($loggerHelper instanceof LoggerHelper)');
$function->invoke($object, $input, $output);
} | @throws ExpectationFailedException
@throws ReflectionException
@throws LogicException | testExecuteWithWongLoggerHelper | php | browscap/browscap | tests/BrowscapTest/Command/ValidateCoreDivisionsCommandTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Command/ValidateCoreDivisionsCommandTest.php | MIT |
public function testExecuteWithoutResourcesOption(): void
{
$input = $this->getMockBuilder(InputInterface::class)
->getMock();
$input->expects(self::once())
->method('getOption')
->with('resources')
->willReturn(null);
$output = $this->getMockBuilder(OutputInterface::class)
->getMock();
$output->expects(self::never())
->method('writeln');
$logger = $this->getMockBuilder(LoggerInterface::class)
->getMock();
$logger->expects(self::never())
->method('emergency');
$logger->expects(self::never())
->method('alert');
$logger->expects(self::never())
->method('critical');
$logger->expects(self::never())
->method('error');
$logger->expects(self::never())
->method('warning');
$logger->expects(self::never())
->method('notice');
$logger->expects(self::never())
->method('info');
$logger->expects(self::never())
->method('debug');
$logger->expects(self::never())
->method('log');
$loggerHelper = $this->getMockBuilder(LoggerHelper::class)
->getMock();
$loggerHelper->expects(self::once())
->method('create')
->with($output)
->willReturn($logger);
$helperSet = $this->getMockBuilder(HelperSet::class)
->getMock();
$helperSet->expects(self::once())
->method('get')
->with('logger')
->willReturn($loggerHelper);
$object = new ValidateCoreDivisionsCommand();
$object->setHelperSet($helperSet);
$function = new ReflectionMethod($object, 'execute');
$this->expectException(AssertionError::class);
$this->expectExceptionCode(1);
$this->expectExceptionMessage('assert(is_string($resources))');
$function->invoke($object, $input, $output);
} | @throws ExpectationFailedException
@throws ReflectionException
@throws LogicException | testExecuteWithoutResourcesOption | php | browscap/browscap | tests/BrowscapTest/Command/ValidateCoreDivisionsCommandTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Command/ValidateCoreDivisionsCommandTest.php | MIT |
public function testExecuteWithWongRewriteHelper(): void
{
$resources = 'test-resources';
$input = $this->getMockBuilder(InputInterface::class)
->getMock();
$input->expects(self::once())
->method('getOption')
->with('resources')
->willReturn($resources);
$output = $this->getMockBuilder(OutputInterface::class)
->getMock();
$output->expects(self::never())
->method('writeln');
$logger = $this->getMockBuilder(LoggerInterface::class)
->getMock();
$logger->expects(self::never())
->method('emergency');
$logger->expects(self::never())
->method('alert');
$logger->expects(self::never())
->method('critical');
$logger->expects(self::never())
->method('error');
$logger->expects(self::never())
->method('warning');
$logger->expects(self::never())
->method('notice');
$logger->expects(self::once())
->method('info')
->with(sprintf('Resource folder: %s', $resources));
$logger->expects(self::never())
->method('debug');
$logger->expects(self::never())
->method('log');
$rewriteHelper = $this->createMock(RewriteHelper::class);
$loggerHelper = $this->getMockBuilder(LoggerHelper::class)
->getMock();
$loggerHelper->expects(self::once())
->method('create')
->with($output)
->willReturn($logger);
$helperSet = $this->getMockBuilder(HelperSet::class)
->getMock();
$helperSet->expects(self::exactly(2))
->method('get')
->willReturnMap(
[
['logger', $loggerHelper],
['validate', $rewriteHelper],
],
);
$object = new ValidateCoreDivisionsCommand();
$object->setHelperSet($helperSet);
$function = new ReflectionMethod($object, 'execute');
$this->expectException(AssertionError::class);
$this->expectExceptionCode(1);
$this->expectExceptionMessage('assert($validateHelper instanceof ValidateHelper)');
$function->invoke($object, $input, $output);
} | @throws ExpectationFailedException
@throws ReflectionException
@throws LogicException | testExecuteWithWongRewriteHelper | php | browscap/browscap | tests/BrowscapTest/Command/ValidateCoreDivisionsCommandTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Command/ValidateCoreDivisionsCommandTest.php | MIT |
public function testExecuteValidationFailed(): void
{
$resources = 'test-resources';
$schema = 'file://' . realpath(__DIR__ . '/../../../schema/core-divisions.json');
$input = $this->getMockBuilder(InputInterface::class)
->getMock();
$input->expects(self::once())
->method('getOption')
->with('resources')
->willReturn($resources);
$output = $this->getMockBuilder(OutputInterface::class)
->getMock();
$output->expects(self::once())
->method('writeln')
->with('<fg=red>invalid</>', 0);
$logger = $this->getMockBuilder(LoggerInterface::class)
->getMock();
$logger->expects(self::never())
->method('emergency');
$logger->expects(self::never())
->method('alert');
$logger->expects(self::never())
->method('critical');
$logger->expects(self::never())
->method('error');
$logger->expects(self::never())
->method('warning');
$logger->expects(self::never())
->method('notice');
$logger->expects(self::once())
->method('info')
->with(sprintf('Resource folder: %s', $resources));
$logger->expects(self::never())
->method('debug');
$logger->expects(self::never())
->method('log');
$loggerHelper = $this->getMockBuilder(LoggerHelper::class)
->getMock();
$loggerHelper->expects(self::once())
->method('create')
->with($output)
->willReturn($logger);
$validateHelper = $this->getMockBuilder(ValidateHelper::class)
->getMock();
$validateHelper->expects(self::once())
->method('validate')
->with($logger, $resources . '/core', $schema)
->willReturn(true);
$helperSet = $this->getMockBuilder(HelperSet::class)
->getMock();
$helperSet->expects(self::exactly(2))
->method('get')
->willReturnMap(
[
['logger', $loggerHelper],
['validate', $validateHelper],
],
);
$object = new ValidateCoreDivisionsCommand();
$object->setHelperSet($helperSet);
$function = new ReflectionMethod($object, 'execute');
self::assertSame(Command::FAILURE, $function->invoke($object, $input, $output));
} | @throws ExpectationFailedException
@throws ReflectionException
@throws LogicException | testExecuteValidationFailed | php | browscap/browscap | tests/BrowscapTest/Command/ValidateCoreDivisionsCommandTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Command/ValidateCoreDivisionsCommandTest.php | MIT |
public function testExecuteValidationSuccess(): void
{
$resources = 'test-resources';
$schema = 'file://' . realpath(__DIR__ . '/../../../schema/core-divisions.json');
$input = $this->getMockBuilder(InputInterface::class)
->getMock();
$input->expects(self::once())
->method('getOption')
->with('resources')
->willReturn($resources);
$output = $this->getMockBuilder(OutputInterface::class)
->getMock();
$output->expects(self::once())
->method('writeln')
->with('<fg=green>valid</>', 0);
$logger = $this->getMockBuilder(LoggerInterface::class)
->getMock();
$logger->expects(self::never())
->method('emergency');
$logger->expects(self::never())
->method('alert');
$logger->expects(self::never())
->method('critical');
$logger->expects(self::never())
->method('error');
$logger->expects(self::never())
->method('warning');
$logger->expects(self::never())
->method('notice');
$logger->expects(self::once())
->method('info')
->with(sprintf('Resource folder: %s', $resources));
$logger->expects(self::never())
->method('debug');
$logger->expects(self::never())
->method('log');
$loggerHelper = $this->getMockBuilder(LoggerHelper::class)
->getMock();
$loggerHelper->expects(self::once())
->method('create')
->with($output)
->willReturn($logger);
$validateHelper = $this->getMockBuilder(ValidateHelper::class)
->getMock();
$validateHelper->expects(self::once())
->method('validate')
->with($logger, $resources . '/core', $schema)
->willReturn(false);
$helperSet = $this->getMockBuilder(HelperSet::class)
->getMock();
$helperSet->expects(self::exactly(2))
->method('get')
->willReturnMap(
[
['logger', $loggerHelper],
['validate', $validateHelper],
],
);
$object = new ValidateCoreDivisionsCommand();
$object->setHelperSet($helperSet);
$function = new ReflectionMethod($object, 'execute');
self::assertSame(Command::SUCCESS, $function->invoke($object, $input, $output));
} | @throws ExpectationFailedException
@throws ReflectionException
@throws LogicException | testExecuteValidationSuccess | php | browscap/browscap | tests/BrowscapTest/Command/ValidateCoreDivisionsCommandTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Command/ValidateCoreDivisionsCommandTest.php | MIT |
public function testExecuteWithWongLoggerHelper(): void
{
$input = $this->getMockBuilder(InputInterface::class)
->getMock();
$input->expects(self::never())
->method('getOption');
$output = $this->getMockBuilder(OutputInterface::class)
->getMock();
$output->expects(self::never())
->method('writeln');
$validateHelper = $this->createMock(ValidateHelper::class);
$helperSet = $this->getMockBuilder(HelperSet::class)
->getMock();
$helperSet->expects(self::once())
->method('get')
->with('logger')
->willReturn($validateHelper);
$object = new ValidateDevicesCommand();
$object->setHelperSet($helperSet);
$function = new ReflectionMethod($object, 'execute');
$this->expectException(AssertionError::class);
$this->expectExceptionCode(1);
$this->expectExceptionMessage('assert($loggerHelper instanceof LoggerHelper)');
$function->invoke($object, $input, $output);
} | @throws ExpectationFailedException
@throws ReflectionException
@throws LogicException | testExecuteWithWongLoggerHelper | php | browscap/browscap | tests/BrowscapTest/Command/ValidateDevicesCommandTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Command/ValidateDevicesCommandTest.php | MIT |
public function testExecuteWithoutResourcesOption(): void
{
$input = $this->getMockBuilder(InputInterface::class)
->getMock();
$input->expects(self::once())
->method('getOption')
->with('resources')
->willReturn(null);
$output = $this->getMockBuilder(OutputInterface::class)
->getMock();
$output->expects(self::never())
->method('writeln');
$logger = $this->getMockBuilder(LoggerInterface::class)
->getMock();
$logger->expects(self::never())
->method('emergency');
$logger->expects(self::never())
->method('alert');
$logger->expects(self::never())
->method('critical');
$logger->expects(self::never())
->method('error');
$logger->expects(self::never())
->method('warning');
$logger->expects(self::never())
->method('notice');
$logger->expects(self::never())
->method('info');
$logger->expects(self::never())
->method('debug');
$logger->expects(self::never())
->method('log');
$loggerHelper = $this->getMockBuilder(LoggerHelper::class)
->getMock();
$loggerHelper->expects(self::once())
->method('create')
->with($output)
->willReturn($logger);
$helperSet = $this->getMockBuilder(HelperSet::class)
->getMock();
$helperSet->expects(self::once())
->method('get')
->with('logger')
->willReturn($loggerHelper);
$object = new ValidateDevicesCommand();
$object->setHelperSet($helperSet);
$function = new ReflectionMethod($object, 'execute');
$this->expectException(AssertionError::class);
$this->expectExceptionCode(1);
$this->expectExceptionMessage('assert(is_string($resources))');
$function->invoke($object, $input, $output);
} | @throws ExpectationFailedException
@throws ReflectionException
@throws LogicException | testExecuteWithoutResourcesOption | php | browscap/browscap | tests/BrowscapTest/Command/ValidateDevicesCommandTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Command/ValidateDevicesCommandTest.php | MIT |
public function testExecuteWithWongRewriteHelper(): void
{
$resources = 'test-resources';
$input = $this->getMockBuilder(InputInterface::class)
->getMock();
$input->expects(self::once())
->method('getOption')
->with('resources')
->willReturn($resources);
$output = $this->getMockBuilder(OutputInterface::class)
->getMock();
$output->expects(self::never())
->method('writeln');
$logger = $this->getMockBuilder(LoggerInterface::class)
->getMock();
$logger->expects(self::never())
->method('emergency');
$logger->expects(self::never())
->method('alert');
$logger->expects(self::never())
->method('critical');
$logger->expects(self::never())
->method('error');
$logger->expects(self::never())
->method('warning');
$logger->expects(self::never())
->method('notice');
$logger->expects(self::once())
->method('info')
->with(sprintf('Resource folder: %s', $resources));
$logger->expects(self::never())
->method('debug');
$logger->expects(self::never())
->method('log');
$rewriteHelper = $this->createMock(RewriteHelper::class);
$loggerHelper = $this->getMockBuilder(LoggerHelper::class)
->getMock();
$loggerHelper->expects(self::once())
->method('create')
->with($output)
->willReturn($logger);
$helperSet = $this->getMockBuilder(HelperSet::class)
->getMock();
$helperSet->expects(self::exactly(2))
->method('get')
->willReturnMap(
[
['logger', $loggerHelper],
['validate', $rewriteHelper],
],
);
$object = new ValidateDevicesCommand();
$object->setHelperSet($helperSet);
$function = new ReflectionMethod($object, 'execute');
$this->expectException(AssertionError::class);
$this->expectExceptionCode(1);
$this->expectExceptionMessage('assert($validateHelper instanceof ValidateHelper)');
$function->invoke($object, $input, $output);
} | @throws ExpectationFailedException
@throws ReflectionException
@throws LogicException | testExecuteWithWongRewriteHelper | php | browscap/browscap | tests/BrowscapTest/Command/ValidateDevicesCommandTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Command/ValidateDevicesCommandTest.php | MIT |
public function testExecuteValidationFailed(): void
{
$resources = 'test-resources';
$schema = 'file://' . realpath(__DIR__ . '/../../../schema/devices.json');
$input = $this->getMockBuilder(InputInterface::class)
->getMock();
$input->expects(self::once())
->method('getOption')
->with('resources')
->willReturn($resources);
$output = $this->getMockBuilder(OutputInterface::class)
->getMock();
$output->expects(self::once())
->method('writeln')
->with('<fg=red>invalid</>', 0);
$logger = $this->getMockBuilder(LoggerInterface::class)
->getMock();
$logger->expects(self::never())
->method('emergency');
$logger->expects(self::never())
->method('alert');
$logger->expects(self::never())
->method('critical');
$logger->expects(self::never())
->method('error');
$logger->expects(self::never())
->method('warning');
$logger->expects(self::never())
->method('notice');
$logger->expects(self::once())
->method('info')
->with(sprintf('Resource folder: %s', $resources));
$logger->expects(self::never())
->method('debug');
$logger->expects(self::never())
->method('log');
$loggerHelper = $this->getMockBuilder(LoggerHelper::class)
->getMock();
$loggerHelper->expects(self::once())
->method('create')
->with($output)
->willReturn($logger);
$validateHelper = $this->getMockBuilder(ValidateHelper::class)
->getMock();
$validateHelper->expects(self::once())
->method('validate')
->with($logger, $resources . '/devices', $schema)
->willReturn(true);
$helperSet = $this->getMockBuilder(HelperSet::class)
->getMock();
$helperSet->expects(self::exactly(2))
->method('get')
->willReturnMap(
[
['logger', $loggerHelper],
['validate', $validateHelper],
],
);
$object = new ValidateDevicesCommand();
$object->setHelperSet($helperSet);
$function = new ReflectionMethod($object, 'execute');
self::assertSame(Command::FAILURE, $function->invoke($object, $input, $output));
} | @throws ExpectationFailedException
@throws ReflectionException
@throws LogicException | testExecuteValidationFailed | php | browscap/browscap | tests/BrowscapTest/Command/ValidateDevicesCommandTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Command/ValidateDevicesCommandTest.php | MIT |
public function testExecuteValidationSuccess(): void
{
$resources = 'test-resources';
$schema = 'file://' . realpath(__DIR__ . '/../../../schema/devices.json');
$input = $this->getMockBuilder(InputInterface::class)
->getMock();
$input->expects(self::once())
->method('getOption')
->with('resources')
->willReturn($resources);
$output = $this->getMockBuilder(OutputInterface::class)
->getMock();
$output->expects(self::once())
->method('writeln')
->with('<fg=green>valid</>', 0);
$logger = $this->getMockBuilder(LoggerInterface::class)
->getMock();
$logger->expects(self::never())
->method('emergency');
$logger->expects(self::never())
->method('alert');
$logger->expects(self::never())
->method('critical');
$logger->expects(self::never())
->method('error');
$logger->expects(self::never())
->method('warning');
$logger->expects(self::never())
->method('notice');
$logger->expects(self::once())
->method('info')
->with(sprintf('Resource folder: %s', $resources));
$logger->expects(self::never())
->method('debug');
$logger->expects(self::never())
->method('log');
$loggerHelper = $this->getMockBuilder(LoggerHelper::class)
->getMock();
$loggerHelper->expects(self::once())
->method('create')
->with($output)
->willReturn($logger);
$validateHelper = $this->getMockBuilder(ValidateHelper::class)
->getMock();
$validateHelper->expects(self::once())
->method('validate')
->with($logger, $resources . '/devices', $schema)
->willReturn(false);
$helperSet = $this->getMockBuilder(HelperSet::class)
->getMock();
$helperSet->expects(self::exactly(2))
->method('get')
->willReturnMap(
[
['logger', $loggerHelper],
['validate', $validateHelper],
],
);
$object = new ValidateDevicesCommand();
$object->setHelperSet($helperSet);
$function = new ReflectionMethod($object, 'execute');
self::assertSame(Command::SUCCESS, $function->invoke($object, $input, $output));
} | @throws ExpectationFailedException
@throws ReflectionException
@throws LogicException | testExecuteValidationSuccess | php | browscap/browscap | tests/BrowscapTest/Command/ValidateDevicesCommandTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Command/ValidateDevicesCommandTest.php | MIT |
public function testExecuteWithWongLoggerHelper(): void
{
$input = $this->getMockBuilder(InputInterface::class)
->getMock();
$input->expects(self::never())
->method('getOption');
$output = $this->getMockBuilder(OutputInterface::class)
->getMock();
$output->expects(self::never())
->method('writeln');
$validateHelper = $this->createMock(ValidateHelper::class);
$helperSet = $this->getMockBuilder(HelperSet::class)
->getMock();
$helperSet->expects(self::once())
->method('get')
->with('logger')
->willReturn($validateHelper);
$object = new ValidateEnginesCommand();
$object->setHelperSet($helperSet);
$function = new ReflectionMethod($object, 'execute');
$this->expectException(AssertionError::class);
$this->expectExceptionCode(1);
$this->expectExceptionMessage('assert($loggerHelper instanceof LoggerHelper)');
$function->invoke($object, $input, $output);
} | @throws ExpectationFailedException
@throws ReflectionException
@throws LogicException | testExecuteWithWongLoggerHelper | php | browscap/browscap | tests/BrowscapTest/Command/ValidateEnginesCommandTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Command/ValidateEnginesCommandTest.php | MIT |
public function testExecuteWithoutResourcesOption(): void
{
$input = $this->getMockBuilder(InputInterface::class)
->getMock();
$input->expects(self::once())
->method('getOption')
->with('resources')
->willReturn(null);
$output = $this->getMockBuilder(OutputInterface::class)
->getMock();
$output->expects(self::never())
->method('writeln');
$logger = $this->getMockBuilder(LoggerInterface::class)
->getMock();
$logger->expects(self::never())
->method('emergency');
$logger->expects(self::never())
->method('alert');
$logger->expects(self::never())
->method('critical');
$logger->expects(self::never())
->method('error');
$logger->expects(self::never())
->method('warning');
$logger->expects(self::never())
->method('notice');
$logger->expects(self::never())
->method('info');
$logger->expects(self::never())
->method('debug');
$logger->expects(self::never())
->method('log');
$loggerHelper = $this->getMockBuilder(LoggerHelper::class)
->getMock();
$loggerHelper->expects(self::once())
->method('create')
->with($output)
->willReturn($logger);
$helperSet = $this->getMockBuilder(HelperSet::class)
->getMock();
$helperSet->expects(self::once())
->method('get')
->with('logger')
->willReturn($loggerHelper);
$object = new ValidateEnginesCommand();
$object->setHelperSet($helperSet);
$function = new ReflectionMethod($object, 'execute');
$this->expectException(AssertionError::class);
$this->expectExceptionCode(1);
$this->expectExceptionMessage('assert(is_string($resources))');
$function->invoke($object, $input, $output);
} | @throws ExpectationFailedException
@throws ReflectionException
@throws LogicException | testExecuteWithoutResourcesOption | php | browscap/browscap | tests/BrowscapTest/Command/ValidateEnginesCommandTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Command/ValidateEnginesCommandTest.php | MIT |
public function testExecuteWithWongRewriteHelper(): void
{
$resources = 'test-resources';
$input = $this->getMockBuilder(InputInterface::class)
->getMock();
$input->expects(self::once())
->method('getOption')
->with('resources')
->willReturn($resources);
$output = $this->getMockBuilder(OutputInterface::class)
->getMock();
$output->expects(self::never())
->method('writeln');
$logger = $this->getMockBuilder(LoggerInterface::class)
->getMock();
$logger->expects(self::never())
->method('emergency');
$logger->expects(self::never())
->method('alert');
$logger->expects(self::never())
->method('critical');
$logger->expects(self::never())
->method('error');
$logger->expects(self::never())
->method('warning');
$logger->expects(self::never())
->method('notice');
$logger->expects(self::once())
->method('info')
->with(sprintf('Resource folder: %s', $resources));
$logger->expects(self::never())
->method('debug');
$logger->expects(self::never())
->method('log');
$rewriteHelper = $this->createMock(RewriteHelper::class);
$loggerHelper = $this->getMockBuilder(LoggerHelper::class)
->getMock();
$loggerHelper->expects(self::once())
->method('create')
->with($output)
->willReturn($logger);
$helperSet = $this->getMockBuilder(HelperSet::class)
->getMock();
$helperSet->expects(self::exactly(2))
->method('get')
->willReturnMap(
[
['logger', $loggerHelper],
['validate', $rewriteHelper],
],
);
$object = new ValidateEnginesCommand();
$object->setHelperSet($helperSet);
$function = new ReflectionMethod($object, 'execute');
$this->expectException(AssertionError::class);
$this->expectExceptionCode(1);
$this->expectExceptionMessage('assert($validateHelper instanceof ValidateHelper)');
$function->invoke($object, $input, $output);
} | @throws ExpectationFailedException
@throws ReflectionException
@throws LogicException | testExecuteWithWongRewriteHelper | php | browscap/browscap | tests/BrowscapTest/Command/ValidateEnginesCommandTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Command/ValidateEnginesCommandTest.php | MIT |
public function testExecuteValidationFailed(): void
{
$resources = 'test-resources';
$schema = 'file://' . realpath(__DIR__ . '/../../../schema/engines.json');
$input = $this->getMockBuilder(InputInterface::class)
->getMock();
$input->expects(self::once())
->method('getOption')
->with('resources')
->willReturn($resources);
$output = $this->getMockBuilder(OutputInterface::class)
->getMock();
$output->expects(self::once())
->method('writeln')
->with('<fg=red>invalid</>', 0);
$logger = $this->getMockBuilder(LoggerInterface::class)
->getMock();
$logger->expects(self::never())
->method('emergency');
$logger->expects(self::never())
->method('alert');
$logger->expects(self::never())
->method('critical');
$logger->expects(self::never())
->method('error');
$logger->expects(self::never())
->method('warning');
$logger->expects(self::never())
->method('notice');
$logger->expects(self::once())
->method('info')
->with(sprintf('Resource folder: %s', $resources));
$logger->expects(self::never())
->method('debug');
$logger->expects(self::never())
->method('log');
$loggerHelper = $this->getMockBuilder(LoggerHelper::class)
->getMock();
$loggerHelper->expects(self::once())
->method('create')
->with($output)
->willReturn($logger);
$validateHelper = $this->getMockBuilder(ValidateHelper::class)
->getMock();
$validateHelper->expects(self::once())
->method('validate')
->with($logger, $resources . '/engines', $schema)
->willReturn(true);
$helperSet = $this->getMockBuilder(HelperSet::class)
->getMock();
$helperSet->expects(self::exactly(2))
->method('get')
->willReturnMap(
[
['logger', $loggerHelper],
['validate', $validateHelper],
],
);
$object = new ValidateEnginesCommand();
$object->setHelperSet($helperSet);
$function = new ReflectionMethod($object, 'execute');
self::assertSame(Command::FAILURE, $function->invoke($object, $input, $output));
} | @throws ExpectationFailedException
@throws ReflectionException
@throws LogicException | testExecuteValidationFailed | php | browscap/browscap | tests/BrowscapTest/Command/ValidateEnginesCommandTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Command/ValidateEnginesCommandTest.php | MIT |
public function testExecuteValidationSuccess(): void
{
$resources = 'test-resources';
$schema = 'file://' . realpath(__DIR__ . '/../../../schema/engines.json');
$input = $this->getMockBuilder(InputInterface::class)
->getMock();
$input->expects(self::once())
->method('getOption')
->with('resources')
->willReturn($resources);
$output = $this->getMockBuilder(OutputInterface::class)
->getMock();
$output->expects(self::once())
->method('writeln')
->with('<fg=green>valid</>', 0);
$logger = $this->getMockBuilder(LoggerInterface::class)
->getMock();
$logger->expects(self::never())
->method('emergency');
$logger->expects(self::never())
->method('alert');
$logger->expects(self::never())
->method('critical');
$logger->expects(self::never())
->method('error');
$logger->expects(self::never())
->method('warning');
$logger->expects(self::never())
->method('notice');
$logger->expects(self::once())
->method('info')
->with(sprintf('Resource folder: %s', $resources));
$logger->expects(self::never())
->method('debug');
$logger->expects(self::never())
->method('log');
$loggerHelper = $this->getMockBuilder(LoggerHelper::class)
->getMock();
$loggerHelper->expects(self::once())
->method('create')
->with($output)
->willReturn($logger);
$validateHelper = $this->getMockBuilder(ValidateHelper::class)
->getMock();
$validateHelper->expects(self::once())
->method('validate')
->with($logger, $resources . '/engines', $schema)
->willReturn(false);
$helperSet = $this->getMockBuilder(HelperSet::class)
->getMock();
$helperSet->expects(self::exactly(2))
->method('get')
->willReturnMap(
[
['logger', $loggerHelper],
['validate', $validateHelper],
],
);
$object = new ValidateEnginesCommand();
$object->setHelperSet($helperSet);
$function = new ReflectionMethod($object, 'execute');
self::assertSame(Command::SUCCESS, $function->invoke($object, $input, $output));
} | @throws ExpectationFailedException
@throws ReflectionException
@throws LogicException | testExecuteValidationSuccess | php | browscap/browscap | tests/BrowscapTest/Command/ValidateEnginesCommandTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Command/ValidateEnginesCommandTest.php | MIT |
public function testExecuteWithWongLoggerHelper(): void
{
$input = $this->getMockBuilder(InputInterface::class)
->getMock();
$input->expects(self::never())
->method('getOption');
$output = $this->getMockBuilder(OutputInterface::class)
->getMock();
$output->expects(self::never())
->method('writeln');
$validateHelper = $this->createMock(ValidateHelper::class);
$helperSet = $this->getMockBuilder(HelperSet::class)
->getMock();
$helperSet->expects(self::once())
->method('get')
->with('logger')
->willReturn($validateHelper);
$object = new ValidatePlatformsCommand();
$object->setHelperSet($helperSet);
$function = new ReflectionMethod($object, 'execute');
$this->expectException(AssertionError::class);
$this->expectExceptionCode(1);
$this->expectExceptionMessage('assert($loggerHelper instanceof LoggerHelper)');
$function->invoke($object, $input, $output);
} | @throws ExpectationFailedException
@throws ReflectionException
@throws LogicException | testExecuteWithWongLoggerHelper | php | browscap/browscap | tests/BrowscapTest/Command/ValidatePlatformsCommandTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Command/ValidatePlatformsCommandTest.php | MIT |
public function testExecuteWithoutResourcesOption(): void
{
$input = $this->getMockBuilder(InputInterface::class)
->getMock();
$input->expects(self::once())
->method('getOption')
->with('resources')
->willReturn(null);
$output = $this->getMockBuilder(OutputInterface::class)
->getMock();
$output->expects(self::never())
->method('writeln');
$logger = $this->getMockBuilder(LoggerInterface::class)
->getMock();
$logger->expects(self::never())
->method('emergency');
$logger->expects(self::never())
->method('alert');
$logger->expects(self::never())
->method('critical');
$logger->expects(self::never())
->method('error');
$logger->expects(self::never())
->method('warning');
$logger->expects(self::never())
->method('notice');
$logger->expects(self::never())
->method('info');
$logger->expects(self::never())
->method('debug');
$logger->expects(self::never())
->method('log');
$loggerHelper = $this->getMockBuilder(LoggerHelper::class)
->getMock();
$loggerHelper->expects(self::once())
->method('create')
->with($output)
->willReturn($logger);
$helperSet = $this->getMockBuilder(HelperSet::class)
->getMock();
$helperSet->expects(self::once())
->method('get')
->with('logger')
->willReturn($loggerHelper);
$object = new ValidatePlatformsCommand();
$object->setHelperSet($helperSet);
$function = new ReflectionMethod($object, 'execute');
$this->expectException(AssertionError::class);
$this->expectExceptionCode(1);
$this->expectExceptionMessage('assert(is_string($resources))');
$function->invoke($object, $input, $output);
} | @throws ExpectationFailedException
@throws ReflectionException
@throws LogicException | testExecuteWithoutResourcesOption | php | browscap/browscap | tests/BrowscapTest/Command/ValidatePlatformsCommandTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Command/ValidatePlatformsCommandTest.php | MIT |
public function testExecuteWithWongRewriteHelper(): void
{
$resources = 'test-resources';
$input = $this->getMockBuilder(InputInterface::class)
->getMock();
$input->expects(self::once())
->method('getOption')
->with('resources')
->willReturn($resources);
$output = $this->getMockBuilder(OutputInterface::class)
->getMock();
$output->expects(self::never())
->method('writeln');
$logger = $this->getMockBuilder(LoggerInterface::class)
->getMock();
$logger->expects(self::never())
->method('emergency');
$logger->expects(self::never())
->method('alert');
$logger->expects(self::never())
->method('critical');
$logger->expects(self::never())
->method('error');
$logger->expects(self::never())
->method('warning');
$logger->expects(self::never())
->method('notice');
$logger->expects(self::once())
->method('info')
->with(sprintf('Resource folder: %s', $resources));
$logger->expects(self::never())
->method('debug');
$logger->expects(self::never())
->method('log');
$rewriteHelper = $this->createMock(RewriteHelper::class);
$loggerHelper = $this->getMockBuilder(LoggerHelper::class)
->getMock();
$loggerHelper->expects(self::once())
->method('create')
->with($output)
->willReturn($logger);
$helperSet = $this->getMockBuilder(HelperSet::class)
->getMock();
$helperSet->expects(self::exactly(2))
->method('get')
->willReturnMap(
[
['logger', $loggerHelper],
['validate', $rewriteHelper],
],
);
$object = new ValidatePlatformsCommand();
$object->setHelperSet($helperSet);
$function = new ReflectionMethod($object, 'execute');
$this->expectException(AssertionError::class);
$this->expectExceptionCode(1);
$this->expectExceptionMessage('assert($validateHelper instanceof ValidateHelper)');
$function->invoke($object, $input, $output);
} | @throws ExpectationFailedException
@throws ReflectionException
@throws LogicException | testExecuteWithWongRewriteHelper | php | browscap/browscap | tests/BrowscapTest/Command/ValidatePlatformsCommandTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Command/ValidatePlatformsCommandTest.php | MIT |
public function testExecuteValidationFailed(): void
{
$resources = 'test-resources';
$schema = 'file://' . realpath(__DIR__ . '/../../../schema/platforms.json');
$input = $this->getMockBuilder(InputInterface::class)
->getMock();
$input->expects(self::once())
->method('getOption')
->with('resources')
->willReturn($resources);
$output = $this->getMockBuilder(OutputInterface::class)
->getMock();
$output->expects(self::once())
->method('writeln')
->with('<fg=red>invalid</>', 0);
$logger = $this->getMockBuilder(LoggerInterface::class)
->getMock();
$logger->expects(self::never())
->method('emergency');
$logger->expects(self::never())
->method('alert');
$logger->expects(self::never())
->method('critical');
$logger->expects(self::never())
->method('error');
$logger->expects(self::never())
->method('warning');
$logger->expects(self::never())
->method('notice');
$logger->expects(self::once())
->method('info')
->with(sprintf('Resource folder: %s', $resources));
$logger->expects(self::never())
->method('debug');
$logger->expects(self::never())
->method('log');
$loggerHelper = $this->getMockBuilder(LoggerHelper::class)
->getMock();
$loggerHelper->expects(self::once())
->method('create')
->with($output)
->willReturn($logger);
$validateHelper = $this->getMockBuilder(ValidateHelper::class)
->getMock();
$validateHelper->expects(self::once())
->method('validate')
->with($logger, $resources . '/platforms', $schema)
->willReturn(true);
$helperSet = $this->getMockBuilder(HelperSet::class)
->getMock();
$helperSet->expects(self::exactly(2))
->method('get')
->willReturnMap(
[
['logger', $loggerHelper],
['validate', $validateHelper],
],
);
$object = new ValidatePlatformsCommand();
$object->setHelperSet($helperSet);
$function = new ReflectionMethod($object, 'execute');
self::assertSame(Command::FAILURE, $function->invoke($object, $input, $output));
} | @throws ExpectationFailedException
@throws ReflectionException
@throws LogicException | testExecuteValidationFailed | php | browscap/browscap | tests/BrowscapTest/Command/ValidatePlatformsCommandTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Command/ValidatePlatformsCommandTest.php | MIT |
public function testExecuteValidationSuccess(): void
{
$resources = 'test-resources';
$schema = 'file://' . realpath(__DIR__ . '/../../../schema/platforms.json');
$input = $this->getMockBuilder(InputInterface::class)
->getMock();
$input->expects(self::once())
->method('getOption')
->with('resources')
->willReturn($resources);
$output = $this->getMockBuilder(OutputInterface::class)
->getMock();
$output->expects(self::once())
->method('writeln')
->with('<fg=green>valid</>', 0);
$logger = $this->getMockBuilder(LoggerInterface::class)
->getMock();
$logger->expects(self::never())
->method('emergency');
$logger->expects(self::never())
->method('alert');
$logger->expects(self::never())
->method('critical');
$logger->expects(self::never())
->method('error');
$logger->expects(self::never())
->method('warning');
$logger->expects(self::never())
->method('notice');
$logger->expects(self::once())
->method('info')
->with(sprintf('Resource folder: %s', $resources));
$logger->expects(self::never())
->method('debug');
$logger->expects(self::never())
->method('log');
$loggerHelper = $this->getMockBuilder(LoggerHelper::class)
->getMock();
$loggerHelper->expects(self::once())
->method('create')
->with($output)
->willReturn($logger);
$validateHelper = $this->getMockBuilder(ValidateHelper::class)
->getMock();
$validateHelper->expects(self::once())
->method('validate')
->with($logger, $resources . '/platforms', $schema)
->willReturn(false);
$helperSet = $this->getMockBuilder(HelperSet::class)
->getMock();
$helperSet->expects(self::exactly(2))
->method('get')
->willReturnMap(
[
['logger', $loggerHelper],
['validate', $validateHelper],
],
);
$object = new ValidatePlatformsCommand();
$object->setHelperSet($helperSet);
$function = new ReflectionMethod($object, 'execute');
self::assertSame(Command::SUCCESS, $function->invoke($object, $input, $output));
} | @throws ExpectationFailedException
@throws ReflectionException
@throws LogicException | testExecuteValidationSuccess | php | browscap/browscap | tests/BrowscapTest/Command/ValidatePlatformsCommandTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Command/ValidatePlatformsCommandTest.php | MIT |
public function testCreate(): void
{
$output = new NullOutput();
$logger = $this->object->create($output);
static::assertInstanceOf(Logger::class, $logger);
self::assertCount(2, $logger->getHandlers());
self::assertCount(1, $logger->getProcessors());
} | tests creating a logger instance
@throws InvalidArgumentException
@throws ExpectationFailedException | testCreate | php | browscap/browscap | tests/BrowscapTest/Command/Helper/LoggerHelperTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Command/Helper/LoggerHelperTest.php | MIT |
public function testResourceDirNotFound(): void
{
$logger = $this->getMockBuilder(LoggerInterface::class)
->getMock();
$logger->expects(self::never())
->method('emergency');
$logger->expects(self::never())
->method('alert');
$logger->expects(self::once())
->method('critical')
->with(new IsInstanceOf(Throwable::class), []);
$logger->expects(self::never())
->method('error');
$logger->expects(self::never())
->method('warning');
$logger->expects(self::never())
->method('notice');
$logger->expects(self::never())
->method('info');
$logger->expects(self::exactly(2))
->method('debug')
->willReturnMap(
[
['initialize rewrite helper', [], null],
['initialize file finder', [], null],
],
);
$logger->expects(self::never())
->method('log');
$resources = 'test-resource';
$schemaUri = 'file://' . realpath(__DIR__ . '/../../../../schema/browsers.json');
$this->object->rewrite($logger, $resources, $schemaUri);
} | @throws ExpectationFailedException
@throws InvalidNewLineString
@throws InvalidJsonEncodeOptions
@throws InvalidIndentStyle
@throws InvalidIndentSize | testResourceDirNotFound | php | browscap/browscap | tests/BrowscapTest/Command/Helper/RewriteHelperTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Command/Helper/RewriteHelperTest.php | MIT |
public function testResourceDirFoundButWithUnreadableFile(): void
{
$root = vfsStream::setup(self::STORAGE_DIR);
$dir1 = vfsStream::newDirectory('b', 0755);
$dir2 = vfsStream::newDirectory('d', 0755);
$file1 = vfsStream::newFile('foo.txt', 0644);
$file1->setContent('some text');
$file2 = vfsStream::newFile('foo.json', 0044);
$file2->setContent('[]');
$file3 = vfsStream::newFile('test.json', 0644);
$file3->setContent('{}');
$dir1->addChild($file1);
$dir2->addChild($file2);
$root->addChild($dir1);
$root->addChild($dir2);
$root->addChild($file3);
$logger = $this->getMockBuilder(LoggerInterface::class)
->getMock();
$logger->expects(self::never())
->method('emergency');
$logger->expects(self::never())
->method('alert');
$logger->expects(self::exactly(2))
->method('critical')
->willReturnMap(
[
[sprintf('File "%s" is not readable', $root->url() . DIRECTORY_SEPARATOR . $dir2->getName() . DIRECTORY_SEPARATOR . $file2->getName()), [], null],
[sprintf('normalizing File "%s" failed, because it had invalid JSON.', $root->url() . DIRECTORY_SEPARATOR . $file3->getName()), [], null],
],
);
$logger->expects(self::never())
->method('error');
$logger->expects(self::never())
->method('warning');
$logger->expects(self::never())
->method('notice');
$logger->expects(self::exactly(2))
->method('info')
->willReturnMap(
[
[sprintf('source file %s: read', $root->url() . DIRECTORY_SEPARATOR . $dir2->getName() . DIRECTORY_SEPARATOR . $file2->getName()), [], null],
[sprintf('source file %s: read', $root->url() . DIRECTORY_SEPARATOR . 'test.json'), [], null],
],
);
$logger->expects(self::exactly(3))
->method('debug')
->willReturnMap(
[
['initialize rewrite helper', [], null],
['initialize file finder', [], null],
[sprintf('source file %s: normalize content', $root->url() . DIRECTORY_SEPARATOR . 'test.json'), [], null],
],
);
$logger->expects(self::never())
->method('log');
$resources = $root->url();
$schemaUri = 'file://' . realpath(__DIR__ . '/../../../../schema/browsers.json');
$this->object->rewrite($logger, $resources, $schemaUri);
} | @throws InvalidNewLineString
@throws InvalidJsonEncodeOptions
@throws InvalidIndentStyle
@throws InvalidIndentSize | testResourceDirFoundButWithUnreadableFile | php | browscap/browscap | tests/BrowscapTest/Command/Helper/RewriteHelperTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Command/Helper/RewriteHelperTest.php | MIT |
public function testResourceDirFoundButWithUnreadableFileAndSorting(): void
{
$root = vfsStream::setup(self::STORAGE_DIR);
$dir1 = vfsStream::newDirectory('b', 0755);
$dir2 = vfsStream::newDirectory('d', 0755);
$file1 = vfsStream::newFile('foo.txt', 0644);
$file1->setContent('some text');
$file2 = vfsStream::newFile('foo.json', 0044);
$file2->setContent('[]');
$file3 = vfsStream::newFile('test.json', 0644);
$file3->setContent('{}');
$dir1->addChild($file1);
$dir2->addChild($file2);
$root->addChild($dir1);
$root->addChild($dir2);
$root->addChild($file3);
$exception = new JsonException('test');
$logger = $this->getMockBuilder(LoggerInterface::class)
->getMock();
$logger->expects(self::never())
->method('emergency');
$logger->expects(self::never())
->method('alert');
$logger->expects(self::exactly(2))
->method('critical')
->willReturnMap(
[
[sprintf('File "%s" is not readable', $root->url() . DIRECTORY_SEPARATOR . $dir2->getName() . DIRECTORY_SEPARATOR . $file2->getName()), [], null],
[sprintf('sorting File "%s" failed, because it had invalid JSON.', $root->url() . DIRECTORY_SEPARATOR . $file3->getName()), ['Exception' => $exception], null],
],
);
$logger->expects(self::never())
->method('error');
$logger->expects(self::never())
->method('warning');
$logger->expects(self::never())
->method('notice');
$logger->expects(self::exactly(2))
->method('info')
->willReturnMap(
[
[sprintf('source file %s: read', $root->url() . DIRECTORY_SEPARATOR . $dir2->getName() . DIRECTORY_SEPARATOR . $file2->getName()), [], null],
[sprintf('source file %s: read', $root->url() . DIRECTORY_SEPARATOR . 'test.json'), [], null],
],
);
$logger->expects(self::exactly(3))
->method('debug')
->willReturnMap(
[
['initialize rewrite helper', [], null],
['initialize file finder', [], null],
[sprintf('source file %s: sort content', $root->url() . DIRECTORY_SEPARATOR . 'test.json'), [], null],
],
);
$logger->expects(self::never())
->method('log');
$sortHelper = $this->getMockBuilder(Sorter::class)
->getMock();
$sortHelper->expects(self::once())
->method('sort')
->willThrowException($exception);
$helperSet = $this->getMockBuilder(HelperSet::class)
->getMock();
$helperSet->expects(self::once())
->method('get')
->with('sorter')
->willReturn($sortHelper);
$resources = $root->url();
$schemaUri = 'file://' . realpath(__DIR__ . '/../../../../schema/browsers.json');
$this->object->setHelperSet($helperSet);
$this->object->rewrite($logger, $resources, $schemaUri, true);
} | @throws ExpectationFailedException
@throws InvalidNewLineString
@throws InvalidJsonEncodeOptions
@throws InvalidIndentStyle
@throws InvalidIndentSize | testResourceDirFoundButWithUnreadableFileAndSorting | php | browscap/browscap | tests/BrowscapTest/Command/Helper/RewriteHelperTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Command/Helper/RewriteHelperTest.php | MIT |
public function testResourceDirFoundButWithWritingFile(): void
{
$root = vfsStream::setup(self::STORAGE_DIR);
$dir1 = vfsStream::newDirectory('b', 0755);
$dir2 = vfsStream::newDirectory('d', 0755);
$file1 = vfsStream::newFile('foo.txt', 0644);
$file1->setContent('some text');
$file2 = vfsStream::newFile('foo.json', 0044);
$file2->setContent('[]');
$file3 = vfsStream::newFile('test.json', 0644);
$file3->setContent("{\n\"access\": {\n\"type\": \"application\",\n\"properties\": {\n\"Browser\": \"Access\",\n\"Browser_Maker\": \"Microsoft Corporation\"\n},\n\"lite\": false,\n\"standard\": true\n},\n\"1password\": {\n\"type\": \"application\",\n\"properties\": {\n\"Browser\": \"1Password\",\n\"Browser_Maker\": \"AgileBits, Inc.\"\n},\n\"lite\": false,\n\"standard\": true\n}\n}");
$dir1->addChild($file1);
$dir2->addChild($file2);
$root->addChild($dir1);
$root->addChild($dir2);
$root->addChild($file3);
$logger = $this->getMockBuilder(LoggerInterface::class)
->getMock();
$logger->expects(self::never())
->method('emergency');
$logger->expects(self::never())
->method('alert');
$logger->expects(self::once())
->method('critical')
->with(sprintf('File "%s" is not readable', $root->url() . DIRECTORY_SEPARATOR . $dir2->getName() . DIRECTORY_SEPARATOR . $file2->getName()));
$logger->expects(self::never())
->method('error');
$logger->expects(self::never())
->method('warning');
$logger->expects(self::never())
->method('notice');
$logger->expects(self::exactly(2))
->method('info')
->willReturnMap(
[
[sprintf('source file %s: read', $root->url() . DIRECTORY_SEPARATOR . $dir2->getName() . DIRECTORY_SEPARATOR . $file2->getName()), [], null],
[sprintf('source file %s: read', $root->url() . DIRECTORY_SEPARATOR . 'test.json'), [], null],
],
);
$logger->expects(self::exactly(4))
->method('debug')
->willReturnMap(
[
['initialize rewrite helper', [], null],
['initialize file finder', [], null],
[sprintf('source file %s: normalize content', $root->url() . DIRECTORY_SEPARATOR . 'test.json'), [], null],
[sprintf('source file %s: write content', $root->url() . DIRECTORY_SEPARATOR . 'test.json'), [], null],
],
);
$logger->expects(self::never())
->method('log');
$resources = $root->url();
$schemaUri = 'file://' . realpath(__DIR__ . '/../../../../schema/browsers.json');
$this->object->rewrite($logger, $resources, $schemaUri);
self::assertSame("{\n \"1password\": {\n \"lite\": false,\n \"properties\": {\n \"Browser\": \"1Password\",\n \"Browser_Maker\": \"AgileBits, Inc.\"\n },\n \"standard\": true,\n \"type\": \"application\"\n },\n \"access\": {\n \"lite\": false,\n \"properties\": {\n \"Browser\": \"Access\",\n \"Browser_Maker\": \"Microsoft Corporation\"\n },\n \"standard\": true,\n \"type\": \"application\"\n }\n}\n", $file3->getContent());
} | @throws ExpectationFailedException
@throws InvalidNewLineString
@throws InvalidJsonEncodeOptions
@throws InvalidIndentStyle
@throws InvalidIndentSize | testResourceDirFoundButWithWritingFile | php | browscap/browscap | tests/BrowscapTest/Command/Helper/RewriteHelperTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Command/Helper/RewriteHelperTest.php | MIT |
protected function setUp(): void
{
$this->object = new Processor($this->resourceDir);
} | Run before each test, creates a new Processor object | setUp | php | browscap/browscap | tests/BrowscapTest/Coverage/ProcessorTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Coverage/ProcessorTest.php | MIT |
public static function jsonStructureProvider(): array
{
return [
['test1.json', ['statementCount' => 5, 'branchCount' => 1, 'functionCount' => 1]],
['test2.json', ['statementCount' => 15, 'branchCount' => 3, 'functionCount' => 3]],
];
} | Data provider for the testJsonStructure test
@return array<int, array<int, array<string, int>|string>> | jsonStructureProvider | php | browscap/browscap | tests/BrowscapTest/Coverage/ProcessorTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Coverage/ProcessorTest.php | MIT |
public function testJsonStructure(string $fileName, array $expected): void
{
$content = file_get_contents($this->resourceDir . $fileName);
assert(is_string($content));
$coverage = $this->object->processFile(
$fileName,
$content,
[],
);
self::assertCount($expected['statementCount'], $coverage['statementMap']);
self::assertCount($expected['statementCount'], $coverage['s']);
self::assertCount($expected['branchCount'], $coverage['branchMap']);
self::assertCount($expected['branchCount'], $coverage['b']);
self::assertCount($expected['functionCount'], $coverage['fnMap']);
self::assertCount($expected['functionCount'], $coverage['f']);
} | This test verifies that the different structures were extracted from the test JSON files
@param array<string, int> $expected
@dataProvider jsonStructureProvider | testJsonStructure | php | browscap/browscap | tests/BrowscapTest/Coverage/ProcessorTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Coverage/ProcessorTest.php | MIT |
public static function coverageProvider(): array
{
return [
'test1-no-coverage' => [
'test1.json',
[],
[
's' => 0,
'b' => 0,
'f' => 0,
],
],
'test1-partial-coverage' => [
'test1.json',
['u0::c0::d::pPlatform_1'],
[
's' => 4,
'b' => 1,
'f' => 1,
],
],
'test1-full-coverage' => [
'test1.json',
['u0::c0::d::pPlatform_1', 'u0::c0::d::pPlatform_2'],
[
's' => 8,
'b' => 2,
'f' => 2,
],
],
'test1-full-coverage-double' => [
'test1.json',
['u0::c0::d::pPlatform_1', 'u0::c0::d::pPlatform_2', 'u0::c0::d::pPlatform_2'],
[
's' => 12,
'b' => 3,
'f' => 3,
],
],
'test2-no-coverage' => [
'test2.json',
[],
[
's' => 0,
'b' => 0,
'f' => 0,
],
],
'test2-partial-coverage' => [
'test2.json',
['u0::c0::d::pPlatform_1'],
[
's' => 4,
'b' => 1,
'f' => 1,
],
],
'test2-full-coverage' => [
'test2.json',
[
'u0::c0::d::pPlatform_1',
'u0::c0::d::pPlatform_2',
'u0::c1::ddevice1::pPlatform_1',
'u0::c1::ddevice2::pPlatform_2',
'u1::c0::d::p',
],
[
's' => 22,
'b' => 6,
'f' => 5,
],
],
];
} | Data provider for the testCoverage test
@return array<string, array<int, array<int|string, int|string>|string>> | coverageProvider | php | browscap/browscap | tests/BrowscapTest/Coverage/ProcessorTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Coverage/ProcessorTest.php | MIT |
public function testCoverage(string $fileName, array $coveredIds, array $expected): void
{
$content = file_get_contents($this->resourceDir . $fileName);
assert(is_string($content));
$coverage = $this->object->processFile(
$fileName,
$content,
$coveredIds,
);
self::assertSame($expected['s'], array_sum($coverage['s']));
self::assertSame($expected['f'], array_sum($coverage['f']));
$branchSum = 0;
foreach ($coverage['b'] as $branch) {
$branchSum += array_sum($branch);
}
self::assertSame($expected['b'], $branchSum);
} | Tests that the amount of covered statements/branches/functions matches expected
@param array<int|string, string> $coveredIds
@param array<string, int> $expected
@dataProvider coverageProvider | testCoverage | php | browscap/browscap | tests/BrowscapTest/Coverage/ProcessorTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Coverage/ProcessorTest.php | MIT |
public function testPatternIdGrouping(): void
{
$patternIds = [
'abc.json::u0::c0::d::p',
'abc.json::u0::c1::d::p',
'def.json::u0::c1::d::p',
'ghi.json::u0::c1::d::p',
];
$this->object->setCoveredPatternIds($patternIds);
self::assertSame(
[
'abc.json' => ['u0::c0::d::p', 'u0::c1::d::p'],
'def.json' => ['u0::c1::d::p'],
'ghi.json' => ['u0::c1::d::p'],
],
$this->object->getCoveredPatternIds(),
);
} | Tests that the collected patterns ids are grouped by filename prefix | testPatternIdGrouping | php | browscap/browscap | tests/BrowscapTest/Coverage/ProcessorTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Coverage/ProcessorTest.php | MIT |
public function testGetter(): void
{
$properties = ['Browser' => 'def'];
$standard = false;
$lite = true;
$type = 'application';
$object = new Browser($properties, $type, $lite, $standard);
static::assertSame($properties, $object->getProperties());
static::assertFalse($object->isStandard());
static::assertTrue($object->isLite());
static::assertSame($type, $object->getType());
} | tests setter and getter for the match property
@throws ExpectationFailedException | testGetter | php | browscap/browscap | tests/BrowscapTest/Data/BrowserTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Data/BrowserTest.php | MIT |
public function testGetDevice(): void
{
$expectedDevice = $this->createMock(Device::class);
assert($expectedDevice instanceof Device);
$this->object->addDevice('Foobar', $expectedDevice);
$device = $this->object->getDevice('Foobar');
static::assertSame($expectedDevice, $device);
} | @throws ExpectationFailedException
@throws OutOfBoundsException
@throws DuplicateDataException | testGetDevice | php | browscap/browscap | tests/BrowscapTest/Data/DataCollectionTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Data/DataCollectionTest.php | MIT |
public function testGetBrowser(): void
{
$expectedBrowser = $this->createMock(Browser::class);
assert($expectedBrowser instanceof Browser);
$this->object->addBrowser('Foobar', $expectedBrowser);
$browser = $this->object->getBrowser('Foobar');
static::assertSame($expectedBrowser, $browser);
} | @throws ExpectationFailedException
@throws OutOfBoundsException
@throws DuplicateDataException | testGetBrowser | php | browscap/browscap | tests/BrowscapTest/Data/DataCollectionTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Data/DataCollectionTest.php | MIT |
public function testGetter(): void
{
$properties = ['abc' => 'def'];
$standard = false;
$type = 'tablet';
$object = new Device($properties, $type, $standard);
static::assertSame($properties, $object->getProperties());
static::assertFalse($object->isStandard());
static::assertSame($type, $object->getType());
} | tests setter and getter for the match property
@throws ExpectationFailedException | testGetter | php | browscap/browscap | tests/BrowscapTest/Data/DeviceTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Data/DeviceTest.php | MIT |
public function testGetProperties(): void
{
$properties = ['RenderingEngine_Name' => 'def'];
$object = new Engine($properties);
static::assertSame($properties, $object->getProperties());
} | tests setter and getter for the engine properties
@throws ExpectationFailedException | testGetProperties | php | browscap/browscap | tests/BrowscapTest/Data/EngineTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Data/EngineTest.php | MIT |
public function testParseDoesNothingOnEmptyDatacollection(): void
{
$collection = $this->getMockBuilder(DataCollection::class)
->disableOriginalConstructor()
->onlyMethods(['getDivisions', 'getDefaultProperties', 'getDevice', 'getPlatform', 'getEngine', 'getBrowser'])
->getMock();
$collection
->expects(static::never())
->method('getDivisions')
->willReturn([]);
$defaultProperties = $this->getMockBuilder(UserAgent::class)
->disableOriginalConstructor()
->onlyMethods(['getUserAgent', 'getProperties'])
->getMock();
$defaultProperties
->expects(static::once())
->method('getProperties')
->willReturn(['avd' => 'xyz']);
$defaultProperties
->expects(static::once())
->method('getUserAgent')
->willReturn('Defaultproperties');
$coreDivision = $this->getMockBuilder(Division::class)
->disableOriginalConstructor()
->onlyMethods(['getUserAgents'])
->getMock();
$coreDivision
->expects(static::once())
->method('getUserAgents')
->willReturn([0 => $defaultProperties]);
$collection
->expects(static::once())
->method('getDefaultProperties')
->willReturn($coreDivision);
$collection
->expects(static::never())
->method('getDevice');
$collection
->expects(static::never())
->method('getPlatform');
$collection
->expects(static::never())
->method('getEngine');
$collection
->expects(static::never())
->method('getBrowser');
$division = $this->getMockBuilder(Division::class)
->disableOriginalConstructor()
->onlyMethods(['getUserAgents'])
->getMock();
$division
->expects(static::once())
->method('getUserAgents')
->willReturn([]);
$property = new ReflectionProperty($this->object, 'collection');
$property->setValue($this->object, $collection);
assert($division instanceof Division);
$result = $this->object->expand($division, 'TestDivision');
static::assertIsArray($result);
static::assertCount(0, $result);
} | tests parsing an empty data collection
@throws ReflectionException
@throws UnexpectedValueException
@throws OutOfBoundsException
@throws ParentNotDefinedException
@throws InvalidParentException
@throws DuplicateDataException | testParseDoesNothingOnEmptyDatacollection | php | browscap/browscap | tests/BrowscapTest/Data/ExpanderTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Data/ExpanderTest.php | MIT |
public function testParseOnNotEmptyDatacollectionWithoutChildren(): void
{
$collection = $this->getMockBuilder(DataCollection::class)
->disableOriginalConstructor()
->onlyMethods(['getDivisions', 'getDefaultProperties', 'getDevice', 'getPlatform', 'getEngine', 'getBrowser'])
->getMock();
$collection
->expects(static::never())
->method('getDivisions')
->willReturn([]);
$defaultProperties = $this->getMockBuilder(UserAgent::class)
->disableOriginalConstructor()
->onlyMethods(['getUserAgent', 'getProperties'])
->getMock();
$defaultProperties
->expects(static::exactly(2))
->method('getProperties')
->willReturn(['avd' => 'xyz']);
$defaultProperties
->expects(static::once())
->method('getUserAgent')
->willReturn('Defaultproperties');
$coreDivision = $this->getMockBuilder(Division::class)
->disableOriginalConstructor()
->onlyMethods(['getUserAgents'])
->getMock();
$coreDivision
->expects(static::once())
->method('getUserAgents')
->willReturn([0 => $defaultProperties]);
$collection
->expects(static::once())
->method('getDefaultProperties')
->willReturn($coreDivision);
$collection
->expects(static::never())
->method('getDevice');
$collection
->expects(static::never())
->method('getPlatform');
$collection
->expects(static::never())
->method('getEngine');
$collection
->expects(static::never())
->method('getBrowser');
$useragent = $this->getMockBuilder(UserAgent::class)
->disableOriginalConstructor()
->onlyMethods(['getUserAgent', 'getProperties'])
->getMock();
$useragent
->expects(static::once())
->method('getUserAgent')
->willReturn('abc');
$useragent
->expects(static::once())
->method('getProperties')
->willReturn([
'Parent' => 'Defaultproperties',
'Version' => '1.0',
'MajorVer' => 1,
'Browser' => 'xyz',
]);
$division = $this->getMockBuilder(Division::class)
->disableOriginalConstructor()
->onlyMethods(['getUserAgents'])
->getMock();
$division
->expects(static::once())
->method('getUserAgents')
->willReturn(
[0 => $useragent],
);
$property = new ReflectionProperty($this->object, 'collection');
$property->setValue($this->object, $collection);
assert($division instanceof Division);
$result = $this->object->expand($division, 'TestDivision');
static::assertIsArray($result);
static::assertCount(1, $result);
} | tests parsing a not empty data collection without children
@throws ReflectionException
@throws UnexpectedValueException
@throws OutOfBoundsException
@throws ParentNotDefinedException
@throws InvalidParentException
@throws DuplicateDataException | testParseOnNotEmptyDatacollectionWithoutChildren | php | browscap/browscap | tests/BrowscapTest/Data/ExpanderTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Data/ExpanderTest.php | MIT |
public function testParseOnNotEmptyDatacollectionWithChildren(): void
{
$collection = $this->getMockBuilder(DataCollection::class)
->disableOriginalConstructor()
->onlyMethods(['getDivisions', 'getDefaultProperties', 'getDevice', 'getPlatform', 'getEngine', 'getBrowser'])
->getMock();
$collection
->expects(static::never())
->method('getDivisions')
->willReturn([]);
$defaultProperties = $this->getMockBuilder(UserAgent::class)
->disableOriginalConstructor()
->onlyMethods(['getUserAgent', 'getProperties'])
->getMock();
$defaultProperties
->expects(static::exactly(3))
->method('getProperties')
->willReturn(['avd' => 'xyz']);
$defaultProperties
->expects(static::once())
->method('getUserAgent')
->willReturn('Defaultproperties');
$coreDivision = $this->getMockBuilder(Division::class)
->disableOriginalConstructor()
->onlyMethods(['getUserAgents'])
->getMock();
$coreDivision
->expects(static::once())
->method('getUserAgents')
->willReturn([0 => $defaultProperties]);
$collection
->expects(static::once())
->method('getDefaultProperties')
->willReturn($coreDivision);
$collection
->expects(static::never())
->method('getDevice');
$collection
->expects(static::never())
->method('getPlatform');
$collection
->expects(static::never())
->method('getEngine');
$collection
->expects(static::never())
->method('getBrowser');
$useragent = $this->getMockBuilder(UserAgent::class)
->disableOriginalConstructor()
->onlyMethods(['getUserAgent', 'getProperties', 'getChildren', 'getPlatform'])
->getMock();
$useragent
->expects(static::once())
->method('getUserAgent')
->willReturn('abc');
$useragent
->expects(static::once())
->method('getProperties')
->willReturn([
'Parent' => 'Defaultproperties',
'Version' => '1.0',
'MajorVer' => 1,
'Browser' => 'xyz',
]);
$useragent
->expects(static::once())
->method('getChildren')
->willReturn([
0 => [
'match' => 'abc*',
'properties' => ['Browser' => 'xyza'],
],
]);
$useragent
->expects(static::once())
->method('getPlatform')
->willReturn(null);
$division = $this->getMockBuilder(Division::class)
->disableOriginalConstructor()
->onlyMethods(['getUserAgents'])
->getMock();
$division
->expects(static::once())
->method('getUserAgents')
->willReturn([0 => $useragent]);
$property = new ReflectionProperty($this->object, 'collection');
$property->setValue($this->object, $collection);
assert($division instanceof Division);
$result = $this->object->expand($division, 'TestDivision');
static::assertIsArray($result);
static::assertCount(2, $result);
} | tests parsing an not empty data collection with children
@throws ReflectionException
@throws UnexpectedValueException
@throws OutOfBoundsException
@throws ParentNotDefinedException
@throws InvalidParentException
@throws DuplicateDataException | testParseOnNotEmptyDatacollectionWithChildren | php | browscap/browscap | tests/BrowscapTest/Data/ExpanderTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Data/ExpanderTest.php | MIT |
public function testParseOnNotEmptyDatacollectionWithChildrenAndDevices(): void
{
$collection = $this->getMockBuilder(DataCollection::class)
->disableOriginalConstructor()
->onlyMethods(['getDivisions', 'getDefaultProperties', 'getDevice', 'getPlatform', 'getEngine', 'getBrowser'])
->getMock();
$collection
->expects(static::never())
->method('getDivisions')
->willReturn([]);
$defaultProperties = $this->getMockBuilder(UserAgent::class)
->disableOriginalConstructor()
->onlyMethods(['getUserAgent', 'getProperties'])
->getMock();
$defaultProperties
->expects(static::exactly(4))
->method('getProperties')
->willReturn(['avd' => 'xyz']);
$defaultProperties
->expects(static::once())
->method('getUserAgent')
->willReturn('Defaultproperties');
$coreDivision = $this->getMockBuilder(Division::class)
->disableOriginalConstructor()
->onlyMethods(['getUserAgents'])
->getMock();
$coreDivision
->expects(static::once())
->method('getUserAgents')
->willReturn([0 => $defaultProperties]);
$device1 = $this->getMockBuilder(Device::class)
->disableOriginalConstructor()
->onlyMethods(['getProperties', 'getType'])
->getMock();
$device1
->expects(static::once())
->method('getProperties')
->willReturn(['avd' => 'xyz']);
$device1
->expects(static::once())
->method('getType')
->willReturn('tablet');
$device2 = $this->getMockBuilder(Device::class)
->disableOriginalConstructor()
->onlyMethods(['getProperties', 'getType'])
->getMock();
$device2
->expects(static::once())
->method('getProperties')
->willReturn(['avd' => 'abc']);
$device2
->expects(static::once())
->method('getType')
->willReturn('mobile');
$collection
->expects(static::once())
->method('getDefaultProperties')
->willReturn($coreDivision);
$collection
->expects(static::exactly(2))
->method('getDevice')
->willReturnMap([['ABC', $device1], ['DEF', $device2]]);
$collection
->expects(static::never())
->method('getPlatform');
$collection
->expects(static::never())
->method('getEngine');
$collection
->expects(static::never())
->method('getBrowser');
$useragent = $this->getMockBuilder(UserAgent::class)
->disableOriginalConstructor()
->onlyMethods(['getUserAgent', 'getProperties', 'getChildren', 'getPlatform'])
->getMock();
$useragent
->expects(static::once())
->method('getUserAgent')
->willReturn('abc');
$useragent
->expects(static::once())
->method('getProperties')
->willReturn([
'Parent' => 'Defaultproperties',
'Version' => '1.0',
'MajorVer' => 1,
'Browser' => 'xyz',
]);
$useragent
->expects(static::once())
->method('getChildren')
->willReturn([
0 => [
'match' => 'abc*#DEVICE#',
'devices' => [
'abc' => 'ABC',
'def' => 'DEF',
],
'properties' => ['Browser' => 'xyza'],
],
]);
$useragent
->expects(static::once())
->method('getPlatform')
->willReturn(null);
$division = $this->getMockBuilder(Division::class)
->disableOriginalConstructor()
->onlyMethods(['getUserAgents'])
->getMock();
$division
->expects(static::once())
->method('getUserAgents')
->willReturn([0 => $useragent]);
$property = new ReflectionProperty($this->object, 'collection');
$property->setValue($this->object, $collection);
assert($division instanceof Division);
$result = $this->object->expand($division, 'TestDivision');
static::assertIsArray($result);
static::assertCount(3, $result);
} | tests parsing a non empty data collection with children and devices
@throws ReflectionException
@throws UnexpectedValueException
@throws OutOfBoundsException
@throws ParentNotDefinedException
@throws InvalidParentException
@throws DuplicateDataException | testParseOnNotEmptyDatacollectionWithChildrenAndDevices | php | browscap/browscap | tests/BrowscapTest/Data/ExpanderTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Data/ExpanderTest.php | MIT |
public function testPatternIdCollectionOnNotEmptyDatacollectionWithChildren(): void
{
$collection = $this->getMockBuilder(DataCollection::class)
->disableOriginalConstructor()
->onlyMethods(['getDivisions', 'getDefaultProperties', 'getDevice', 'getPlatform', 'getEngine', 'getBrowser'])
->getMock();
$defaultProperties = $this->getMockBuilder(UserAgent::class)
->disableOriginalConstructor()
->onlyMethods(['getUserAgent', 'getProperties'])
->getMock();
$defaultProperties
->expects(static::exactly(3))
->method('getProperties')
->willReturn(['avd' => 'xyz']);
$defaultProperties
->expects(static::once())
->method('getUserAgent')
->willReturn('Defaultproperties');
$coreDivision = $this->getMockBuilder(Division::class)
->disableOriginalConstructor()
->onlyMethods(['getUserAgents'])
->getMock();
$coreDivision
->expects(static::once())
->method('getUserAgents')
->willReturn([0 => $defaultProperties]);
$collection
->expects(static::once())
->method('getDefaultProperties')
->willReturn($coreDivision);
$collection
->expects(static::never())
->method('getDevice');
$collection
->expects(static::never())
->method('getPlatform');
$collection
->expects(static::never())
->method('getEngine');
$collection
->expects(static::never())
->method('getBrowser');
$useragent = $this->getMockBuilder(UserAgent::class)
->disableOriginalConstructor()
->onlyMethods(['getUserAgent', 'getProperties', 'getChildren', 'getPlatform'])
->getMock();
$useragent
->expects(static::once())
->method('getUserAgent')
->willReturn('abc');
$useragent
->expects(static::once())
->method('getProperties')
->willReturn([
'Parent' => 'Defaultproperties',
'Version' => '1.0',
'MajorVer' => 1,
'Browser' => 'xyz',
]);
$useragent
->expects(static::once())
->method('getChildren')
->willReturn([
0 => [
'match' => 'abc*',
'properties' => ['Browser' => 'xyza'],
],
]);
$useragent
->expects(static::once())
->method('getPlatform')
->willReturn(null);
$division = $this->getMockBuilder(Division::class)
->disableOriginalConstructor()
->onlyMethods(['getUserAgents', 'getFileName'])
->getMock();
$division
->expects(static::once())
->method('getUserAgents')
->willReturn([0 => $useragent]);
$division
->expects(static::once())
->method('getFileName')
->willReturn('tests/test.json');
$property = new ReflectionProperty($this->object, 'collection');
$property->setValue($this->object, $collection);
assert($division instanceof Division);
$result = $this->object->expand($division, 'TestDivision');
static::assertArrayHasKey('PatternId', $result['abc*']);
static::assertSame('tests/test.json::u0::c0::d::p', $result['abc*']['PatternId']);
} | tests pattern id generation on a not empty data collection with children, no devices or platforms
@throws ReflectionException
@throws UnexpectedValueException
@throws OutOfBoundsException
@throws ParentNotDefinedException
@throws InvalidParentException
@throws DuplicateDataException | testPatternIdCollectionOnNotEmptyDatacollectionWithChildren | php | browscap/browscap | tests/BrowscapTest/Data/ExpanderTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Data/ExpanderTest.php | MIT |
public function testPatternIdCollectionOnNotEmptyDatacollectionWithChildrenAndPlatforms(): void
{
$collection = $this->getMockBuilder(DataCollection::class)
->disableOriginalConstructor()
->onlyMethods(['getDivisions', 'getDefaultProperties', 'getDevice', 'getPlatform', 'getEngine', 'getBrowser'])
->getMock();
$defaultProperties = $this->getMockBuilder(UserAgent::class)
->disableOriginalConstructor()
->onlyMethods(['getUserAgent', 'getProperties'])
->getMock();
$defaultProperties
->expects(static::exactly(3))
->method('getProperties')
->willReturn(['avd' => 'xyz']);
$defaultProperties
->expects(static::once())
->method('getUserAgent')
->willReturn('Defaultproperties');
$coreDivision = $this->getMockBuilder(Division::class)
->disableOriginalConstructor()
->onlyMethods(['getUserAgents'])
->getMock();
$coreDivision
->expects(static::once())
->method('getUserAgents')
->willReturn([0 => $defaultProperties]);
$platform1 = $this->getMockBuilder(Platform::class)
->disableOriginalConstructor()
->onlyMethods(['getProperties', 'getMatch'])
->getMock();
$platform1
->expects(static::once())
->method('getProperties')
->willReturn(['avd' => 'cde']);
$platform1
->expects(static::once())
->method('getMatch')
->willReturn('');
$platform2 = $this->getMockBuilder(Platform::class)
->disableOriginalConstructor()
->onlyMethods(['getProperties', 'getMatch', 'isLite', 'isStandard'])
->getMock();
$platform2
->expects(static::once())
->method('getProperties')
->willReturn(['Platform' => 'abc']);
$platform2
->expects(static::never())
->method('getMatch');
$platform2
->expects(static::once())
->method('isLite')
->willReturn(false);
$platform2
->expects(static::once())
->method('isStandard')
->willReturn(false);
$collection
->expects(static::once())
->method('getDefaultProperties')
->willReturn($coreDivision);
$collection
->expects(static::never())
->method('getDevice');
$collection
->expects(static::exactly(2))
->method('getPlatform')
->willReturnMap(
[['Platform_2', $platform2], ['Platform_1', $platform1]],
);
$collection
->expects(static::never())
->method('getEngine');
$collection
->expects(static::never())
->method('getBrowser');
$useragent = $this->getMockBuilder(UserAgent::class)
->disableOriginalConstructor()
->onlyMethods(['getUserAgent', 'getProperties', 'getChildren', 'getPlatform'])
->getMock();
$useragent
->expects(static::once())
->method('getUserAgent')
->willReturn('abc');
$useragent
->expects(static::once())
->method('getProperties')
->willReturn([
'Parent' => 'Defaultproperties',
'Version' => '1.0',
'MajorVer' => 1,
'Browser' => 'xyz',
]);
$useragent
->expects(static::once())
->method('getChildren')
->willReturn([
0 => [
'match' => 'abc*#PLATFORM#',
'properties' => ['Browser' => 'xyza'],
'platforms' => ['Platform_1'],
],
]);
$useragent
->expects(static::exactly(3))
->method('getPlatform')
->willReturn('Platform_2');
$division = $this->getMockBuilder(Division::class)
->disableOriginalConstructor()
->onlyMethods(['getUserAgents', 'getFileName', 'isLite', 'isStandard', 'getSortIndex'])
->getMock();
$division
->expects(static::once())
->method('getUserAgents')
->willReturn([0 => $useragent]);
$division
->expects(static::once())
->method('getFileName')
->willReturn('tests/test.json');
$division
->expects(static::once())
->method('isLite')
->willReturn(true);
$division
->expects(static::once())
->method('isStandard')
->willReturn(true);
$division
->expects(static::once())
->method('getSortIndex')
->willReturn(42);
$property = new ReflectionProperty($this->object, 'collection');
$property->setValue($this->object, $collection);
assert($division instanceof Division);
$result = $this->object->expand($division, 'TestDivision');
static::assertArrayHasKey('PatternId', $result['abc*']);
static::assertSame('tests/test.json::u0::c0::d::pPlatform_1', $result['abc*']['PatternId']);
} | tests pattern id generation on a not empty data collection with children and platforms, no devices
@throws ReflectionException
@throws UnexpectedValueException
@throws OutOfBoundsException
@throws ParentNotDefinedException
@throws InvalidParentException
@throws DuplicateDataException | testPatternIdCollectionOnNotEmptyDatacollectionWithChildrenAndPlatforms | php | browscap/browscap | tests/BrowscapTest/Data/ExpanderTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Data/ExpanderTest.php | MIT |
public function testPatternIdCollectionOnNotEmptyDatacollectionWithChildrenAndDevices(): void
{
$collection = $this->getMockBuilder(DataCollection::class)
->disableOriginalConstructor()
->onlyMethods(['getDivisions', 'getDefaultProperties', 'getDevice', 'getPlatform', 'getEngine', 'getBrowser'])
->getMock();
$defaultProperties = $this->getMockBuilder(UserAgent::class)
->disableOriginalConstructor()
->onlyMethods(['getUserAgent', 'getProperties'])
->getMock();
$defaultProperties
->expects(static::exactly(4))
->method('getProperties')
->willReturn(['avd' => 'xyz']);
$defaultProperties
->expects(static::once())
->method('getUserAgent')
->willReturn('Defaultproperties');
$coreDivision = $this->getMockBuilder(Division::class)
->disableOriginalConstructor()
->onlyMethods(['getUserAgents'])
->getMock();
$coreDivision
->expects(static::once())
->method('getUserAgents')
->willReturn([0 => $defaultProperties]);
$device1 = $this->getMockBuilder(Device::class)
->disableOriginalConstructor()
->onlyMethods(['getProperties', 'getType'])
->getMock();
$device1
->expects(static::once())
->method('getProperties')
->willReturn([]);
$device1
->expects(static::once())
->method('getType')
->willReturn('tablet');
$device2 = $this->getMockBuilder(Device::class)
->disableOriginalConstructor()
->onlyMethods(['getProperties', 'getType'])
->getMock();
$device2
->expects(static::once())
->method('getProperties')
->willReturn(['avd' => 'fgh']);
$device2
->expects(static::once())
->method('getType')
->willReturn('mobile');
$platform = $this->getMockBuilder(Platform::class)
->disableOriginalConstructor()
->onlyMethods(['getProperties', 'getMatch'])
->getMock();
$platform
->expects(static::exactly(2))
->method('getProperties')
->willReturn(['avd' => 'mno']);
$platform
->expects(static::exactly(2))
->method('getMatch')
->willReturn('');
$collection
->expects(static::once())
->method('getDefaultProperties')
->willReturn($coreDivision);
$collection
->expects(static::exactly(2))
->method('getDevice')
->willReturnMap([['ABC', $device1], ['DEF', $device2]]);
$collection
->expects(static::exactly(2))
->method('getPlatform')
->with('Platform_1')
->willReturn($platform);
$collection
->expects(static::never())
->method('getEngine');
$collection
->expects(static::never())
->method('getBrowser');
$useragent = $this->getMockBuilder(UserAgent::class)
->disableOriginalConstructor()
->onlyMethods(['getUserAgent', 'getProperties', 'getChildren', 'getPlatform'])
->getMock();
$useragent
->expects(static::once())
->method('getUserAgent')
->willReturn('abc');
$useragent
->expects(static::once())
->method('getProperties')
->willReturn([
'Parent' => 'Defaultproperties',
'Version' => '1.0',
'MajorVer' => 1,
'Browser' => 'xyz',
]);
$useragent
->expects(static::once())
->method('getChildren')
->willReturn([
0 => [
'match' => 'abc*#DEVICE#',
'devices' => [
'abc' => 'ABC',
'def' => 'DEF',
],
'platforms' => ['Platform_1'],
'properties' => ['Browser' => 'xyza'],
],
]);
$useragent
->expects(static::once())
->method('getPlatform')
->willReturn(null);
$division = $this->getMockBuilder(Division::class)
->disableOriginalConstructor()
->onlyMethods(['getUserAgents', 'getFileName'])
->getMock();
$division
->expects(static::once())
->method('getUserAgents')
->willReturn([0 => $useragent]);
$division
->expects(static::once())
->method('getFileName')
->willReturn('tests/test.json');
$property = new ReflectionProperty($this->object, 'collection');
$property->setValue($this->object, $collection);
assert($division instanceof Division);
$result = $this->object->expand($division, 'TestDivision');
static::assertArrayHasKey('PatternId', $result['abc*abc']);
static::assertSame('tests/test.json::u0::c0::dabc::pPlatform_1', $result['abc*abc']['PatternId']);
static::assertArrayHasKey('PatternId', $result['abc*def']);
static::assertSame('tests/test.json::u0::c0::ddef::pPlatform_1', $result['abc*def']['PatternId']);
} | tests pattern id generation on a not empty data collection with children and devices, no platforms
@throws ReflectionException
@throws UnexpectedValueException
@throws OutOfBoundsException
@throws ParentNotDefinedException
@throws InvalidParentException
@throws DuplicateDataException | testPatternIdCollectionOnNotEmptyDatacollectionWithChildrenAndDevices | php | browscap/browscap | tests/BrowscapTest/Data/ExpanderTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Data/ExpanderTest.php | MIT |
public function testPatternIdCollectionOnNotEmptyDatacollectionWithChildrenAndDevices2(): void
{
$collection = $this->getMockBuilder(DataCollection::class)
->disableOriginalConstructor()
->onlyMethods(['getDivisions', 'getDefaultProperties', 'getDevice', 'getPlatform', 'getEngine', 'getBrowser'])
->getMock();
$defaultProperties = $this->getMockBuilder(UserAgent::class)
->disableOriginalConstructor()
->onlyMethods(['getUserAgent', 'getProperties'])
->getMock();
$defaultProperties
->expects(static::exactly(6))
->method('getProperties')
->willReturn(['avd' => 'xyz']);
$defaultProperties
->expects(static::once())
->method('getUserAgent')
->willReturn('Defaultproperties');
$coreDivision = $this->getMockBuilder(Division::class)
->disableOriginalConstructor()
->onlyMethods(['getUserAgents'])
->getMock();
$coreDivision
->expects(static::once())
->method('getUserAgents')
->willReturn([0 => $defaultProperties]);
$device1 = $this->getMockBuilder(Device::class)
->disableOriginalConstructor()
->onlyMethods(['getProperties', 'getType'])
->getMock();
$device1
->expects(static::exactly(2))
->method('getProperties')
->willReturn(['Device_Name' => 'D1']);
$device1
->expects(static::exactly(2))
->method('getType')
->willReturn('tablet');
$device2 = $this->getMockBuilder(Device::class)
->disableOriginalConstructor()
->onlyMethods(['getProperties', 'getType'])
->getMock();
$device2
->expects(static::exactly(2))
->method('getProperties')
->willReturn(['Device_Name' => 'D2']);
$device2
->expects(static::exactly(2))
->method('getType')
->willReturn('console');
$platform1 = $this->getMockBuilder(Platform::class)
->disableOriginalConstructor()
->onlyMethods(['getProperties', 'getMatch'])
->getMock();
$platform1
->expects(static::exactly(2))
->method('getProperties')
->willReturn(['Platform' => 'P1']);
$platform1
->expects(static::exactly(2))
->method('getMatch')
->willReturn('*P1*');
$platform2 = $this->getMockBuilder(Platform::class)
->disableOriginalConstructor()
->onlyMethods(['getProperties', 'getMatch'])
->getMock();
$platform2
->expects(static::exactly(2))
->method('getProperties')
->willReturn(['Platform' => 'P2']);
$platform2
->expects(static::exactly(2))
->method('getMatch')
->willReturn('*P2*');
$engine = $this->getMockBuilder(Engine::class)
->disableOriginalConstructor()
->getMock();
$engine
->expects(static::exactly(4))
->method('getProperties')
->willReturn(['avd' => 'rtz']);
$collection
->expects(static::once())
->method('getDefaultProperties')
->willReturn($coreDivision);
$collection
->expects(static::exactly(4))
->method('getDevice')
->willReturnMap([['ABC', $device1], ['DEF', $device2]]);
$collection
->expects(static::exactly(4))
->method('getPlatform')
->willReturnMap([['Platform_1', $platform1], ['Platform_2', $platform2]]);
$collection
->expects(static::exactly(4))
->method('getEngine')
->with('Engine_1')
->willReturn($engine);
$collection
->expects(static::never())
->method('getBrowser');
$useragent = $this->getMockBuilder(UserAgent::class)
->disableOriginalConstructor()
->onlyMethods(['getUserAgent', 'getProperties', 'getChildren', 'getPlatform'])
->getMock();
$useragent
->expects(static::once())
->method('getUserAgent')
->willReturn('abc');
$useragent
->expects(static::once())
->method('getProperties')
->willReturn([
'Parent' => 'Defaultproperties',
'Version' => '1.0',
'MajorVer' => 1,
'Browser' => 'xyz',
]);
$useragent
->expects(static::once())
->method('getChildren')
->willReturn([
0 => [
'match' => 'abc*#DEVICE##PLATFORM#',
'devices' => [
'abc' => 'ABC',
'def' => 'DEF',
],
'engine' => 'Engine_1',
'platforms' => ['Platform_1', 'Platform_2'],
'properties' => ['Browser' => 'xyza'],
],
]);
$useragent
->expects(static::once())
->method('getPlatform')
->willReturn(null);
$division = $this->getMockBuilder(Division::class)
->disableOriginalConstructor()
->onlyMethods(['getUserAgents', 'getFileName', 'getName'])
->getMock();
$division
->expects(static::once())
->method('getUserAgents')
->willReturn([0 => $useragent]);
$division
->expects(static::once())
->method('getFileName')
->willReturn('tests/test.json');
$division
->expects(static::never())
->method('getName');
$property = new ReflectionProperty($this->object, 'collection');
$property->setValue($this->object, $collection);
assert($division instanceof Division);
$result = $this->object->expand($division, 'TestDivision');
static::assertIsArray($result);
static::assertCount(5, $result);
static::assertArrayHasKey('PatternId', $result['abc*abc*P1*']);
static::assertSame('tests/test.json::u0::c0::dabc::pPlatform_1', $result['abc*abc*P1*']['PatternId']);
static::assertArrayHasKey('PatternId', $result['abc*abc*P2*']);
static::assertSame('tests/test.json::u0::c0::dabc::pPlatform_2', $result['abc*abc*P2*']['PatternId']);
static::assertArrayHasKey('PatternId', $result['abc*def*P1*']);
static::assertSame('tests/test.json::u0::c0::ddef::pPlatform_1', $result['abc*def*P1*']['PatternId']);
static::assertArrayHasKey('PatternId', $result['abc*def*P2*']);
static::assertSame('tests/test.json::u0::c0::ddef::pPlatform_2', $result['abc*def*P2*']['PatternId']);
} | tests pattern id generation on a not empty data collection with children and devices, no platforms
@throws ReflectionException
@throws UnexpectedValueException
@throws OutOfBoundsException
@throws ParentNotDefinedException
@throws InvalidParentException
@throws DuplicateDataException | testPatternIdCollectionOnNotEmptyDatacollectionWithChildrenAndDevices2 | php | browscap/browscap | tests/BrowscapTest/Data/ExpanderTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Data/ExpanderTest.php | MIT |
public function testPatternIdCollectionOnNotEmptyDatacollectionWithChildrenAndDevices3(): void
{
$collection = $this->getMockBuilder(DataCollection::class)
->disableOriginalConstructor()
->onlyMethods(['getDivisions', 'getDefaultProperties', 'getDevice', 'getPlatform', 'getEngine', 'getBrowser'])
->getMock();
$defaultProperties = $this->getMockBuilder(UserAgent::class)
->disableOriginalConstructor()
->onlyMethods(['getUserAgent', 'getProperties'])
->getMock();
$defaultProperties
->expects(static::exactly(6))
->method('getProperties')
->willReturn(['avd' => 'xyz']);
$defaultProperties
->expects(static::once())
->method('getUserAgent')
->willReturn('Defaultproperties');
$coreDivision = $this->getMockBuilder(Division::class)
->disableOriginalConstructor()
->onlyMethods(['getUserAgents'])
->getMock();
$coreDivision
->expects(static::once())
->method('getUserAgents')
->willReturn([0 => $defaultProperties]);
$device1 = $this->getMockBuilder(Device::class)
->disableOriginalConstructor()
->onlyMethods(['getProperties', 'getType'])
->getMock();
$device1
->expects(static::exactly(2))
->method('getProperties')
->willReturn(['Device_Name' => 'D1']);
$device1
->expects(static::exactly(2))
->method('getType')
->willReturn('tv');
$device2 = $this->getMockBuilder(Device::class)
->disableOriginalConstructor()
->onlyMethods(['getProperties', 'getType'])
->getMock();
$device2
->expects(static::exactly(2))
->method('getProperties')
->willReturn(['Device_Name' => 'D2']);
$device2
->expects(static::exactly(2))
->method('getType')
->willReturn('car-entertainment-system');
$platform1 = $this->getMockBuilder(Platform::class)
->disableOriginalConstructor()
->onlyMethods(['getProperties', 'getMatch'])
->getMock();
$platform1
->expects(static::exactly(2))
->method('getProperties')
->willReturn(['Platform' => 'P1']);
$platform1
->expects(static::exactly(2))
->method('getMatch')
->willReturn('*P1*');
$platform2 = $this->getMockBuilder(Platform::class)
->disableOriginalConstructor()
->onlyMethods(['getProperties', 'getMatch'])
->getMock();
$platform2
->expects(static::exactly(2))
->method('getProperties')
->willReturn(['Platform' => 'P2']);
$platform2
->expects(static::exactly(2))
->method('getMatch')
->willReturn('*P2*');
$engine = $this->getMockBuilder(Engine::class)
->disableOriginalConstructor()
->getMock();
$engine
->expects(static::exactly(4))
->method('getProperties')
->willReturn([]);
$browser = $this->getMockBuilder(Browser::class)
->disableOriginalConstructor()
->getMock();
$browser
->expects(static::exactly(4))
->method('getProperties')
->willReturn(['avd' => 'xyz']);
$collection
->expects(static::once())
->method('getDefaultProperties')
->willReturn($coreDivision);
$collection
->expects(static::exactly(4))
->method('getDevice')
->willReturnMap([['ABC', $device1], ['DEF', $device2]]);
$collection
->expects(static::exactly(4))
->method('getPlatform')
->willReturnMap([['Platform_1', $platform1], ['Platform_2', $platform2]]);
$collection
->expects(static::exactly(4))
->method('getEngine')
->with('Engine_1')
->willReturn($engine);
$collection
->expects(static::exactly(4))
->method('getBrowser')
->with('Browser_1')
->willReturn($browser);
$useragent = $this->getMockBuilder(UserAgent::class)
->disableOriginalConstructor()
->onlyMethods(['getUserAgent', 'getProperties', 'getChildren', 'getPlatform'])
->getMock();
$useragent
->expects(static::once())
->method('getUserAgent')
->willReturn('abc');
$useragent
->expects(static::once())
->method('getProperties')
->willReturn([
'Parent' => 'Defaultproperties',
'Version' => '1.0',
'MajorVer' => 1,
'Browser' => 'xyz',
]);
$useragent
->expects(static::once())
->method('getChildren')
->willReturn([
0 => [
'match' => 'abc*#DEVICE##PLATFORM#',
'devices' => [
'abc' => 'ABC',
'def' => 'DEF',
],
'engine' => 'Engine_1',
'browser' => 'Browser_1',
'platforms' => ['Platform_1', 'Platform_2'],
'properties' => ['Browser' => 'xyza'],
],
]);
$useragent
->expects(static::once())
->method('getPlatform')
->willReturn(null);
$division = $this->getMockBuilder(Division::class)
->disableOriginalConstructor()
->onlyMethods(['getUserAgents', 'getFileName', 'getName'])
->getMock();
$division
->expects(static::once())
->method('getUserAgents')
->willReturn([0 => $useragent]);
$division
->expects(static::once())
->method('getFileName')
->willReturn('tests/test.json');
$division
->expects(static::never())
->method('getName');
$property = new ReflectionProperty($this->object, 'collection');
$property->setValue($this->object, $collection);
assert($division instanceof Division);
$result = $this->object->expand($division, 'TestDivision');
static::assertIsArray($result);
static::assertCount(5, $result);
static::assertArrayHasKey('PatternId', $result['abc*abc*P1*']);
static::assertSame('tests/test.json::u0::c0::dabc::pPlatform_1', $result['abc*abc*P1*']['PatternId']);
static::assertArrayHasKey('PatternId', $result['abc*abc*P2*']);
static::assertSame('tests/test.json::u0::c0::dabc::pPlatform_2', $result['abc*abc*P2*']['PatternId']);
static::assertArrayHasKey('PatternId', $result['abc*def*P1*']);
static::assertSame('tests/test.json::u0::c0::ddef::pPlatform_1', $result['abc*def*P1*']['PatternId']);
static::assertArrayHasKey('PatternId', $result['abc*def*P2*']);
static::assertSame('tests/test.json::u0::c0::ddef::pPlatform_2', $result['abc*def*P2*']['PatternId']);
} | tests pattern id generation on a not empty data collection with children and devices, no platforms
@throws ReflectionException
@throws UnexpectedValueException
@throws OutOfBoundsException
@throws ParentNotDefinedException
@throws InvalidParentException
@throws DuplicateDataException | testPatternIdCollectionOnNotEmptyDatacollectionWithChildrenAndDevices3 | php | browscap/browscap | tests/BrowscapTest/Data/ExpanderTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Data/ExpanderTest.php | MIT |
public function testPatternIdCollectionOnNotEmptyDatacollectionWithChildrenPlatformsAndDevices(): void
{
$collection = $this->getMockBuilder(DataCollection::class)
->disableOriginalConstructor()
->onlyMethods(['getDivisions', 'getDefaultProperties', 'getDevice', 'getPlatform', 'getEngine', 'getBrowser'])
->getMock();
$defaultProperties = $this->getMockBuilder(UserAgent::class)
->disableOriginalConstructor()
->onlyMethods(['getUserAgent', 'getProperties'])
->getMock();
$defaultProperties
->expects(static::exactly(4))
->method('getProperties')
->willReturn(['avd' => 'xyz']);
$defaultProperties
->expects(static::once())
->method('getUserAgent')
->willReturn('Defaultproperties');
$coreDivision = $this->getMockBuilder(Division::class)
->disableOriginalConstructor()
->onlyMethods(['getUserAgents'])
->getMock();
$coreDivision
->expects(static::once())
->method('getUserAgents')
->willReturn([0 => $defaultProperties]);
$device1 = $this->getMockBuilder(Device::class)
->disableOriginalConstructor()
->onlyMethods(['getProperties', 'getType'])
->getMock();
$device1
->expects(static::once())
->method('getProperties')
->willReturn(['avd' => 'abc']);
$device1
->expects(static::once())
->method('getType')
->willReturn('tablet');
$device2 = $this->getMockBuilder(Device::class)
->disableOriginalConstructor()
->onlyMethods(['getProperties', 'getType'])
->getMock();
$device2
->expects(static::once())
->method('getProperties')
->willReturn(['avd' => 'def']);
$device2
->expects(static::once())
->method('getType')
->willReturn('mobile');
$collection
->expects(static::once())
->method('getDefaultProperties')
->willReturn($coreDivision);
$collection
->expects(static::exactly(2))
->method('getDevice')
->willReturnMap([['ABC', $device1], ['DEF', $device2]]);
$collection
->expects(static::never())
->method('getPlatform');
$collection
->expects(static::never())
->method('getEngine');
$collection
->expects(static::never())
->method('getBrowser');
$useragent = $this->getMockBuilder(UserAgent::class)
->disableOriginalConstructor()
->onlyMethods(['getUserAgent', 'getProperties', 'getChildren', 'getPlatform'])
->getMock();
$useragent
->expects(static::once())
->method('getUserAgent')
->willReturn('abc');
$useragent
->expects(static::once())
->method('getProperties')
->willReturn([
'Parent' => 'Defaultproperties',
'Version' => '1.0',
'MajorVer' => 1,
'Browser' => 'xyz',
]);
$useragent
->expects(static::once())
->method('getChildren')
->willReturn([
0 => [
'match' => 'abc*#DEVICE#',
'devices' => [
'abc' => 'ABC',
'def' => 'DEF',
],
'properties' => ['Browser' => 'xyza'],
],
]);
$useragent
->expects(static::once())
->method('getPlatform')
->willReturn(null);
$division = $this->getMockBuilder(Division::class)
->disableOriginalConstructor()
->onlyMethods(['getUserAgents', 'getFileName'])
->getMock();
$division
->expects(static::once())
->method('getUserAgents')
->willReturn([0 => $useragent]);
$division
->expects(static::once())
->method('getFileName')
->willReturn('tests/test.json');
$property = new ReflectionProperty($this->object, 'collection');
$property->setValue($this->object, $collection);
assert($division instanceof Division);
$result = $this->object->expand($division, 'TestDivision');
static::assertArrayHasKey('PatternId', $result['abc*abc']);
static::assertSame('tests/test.json::u0::c0::dabc::p', $result['abc*abc']['PatternId']);
static::assertArrayHasKey('PatternId', $result['abc*def']);
static::assertSame('tests/test.json::u0::c0::ddef::p', $result['abc*def']['PatternId']);
} | tests pattern id generation on a not empty data collection with children, platforms and devices
@throws ReflectionException
@throws UnexpectedValueException
@throws OutOfBoundsException
@throws ParentNotDefinedException
@throws InvalidParentException
@throws DuplicateDataException | testPatternIdCollectionOnNotEmptyDatacollectionWithChildrenPlatformsAndDevices | php | browscap/browscap | tests/BrowscapTest/Data/ExpanderTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Data/ExpanderTest.php | MIT |
public function testPatternIdCollectionOnNotEmptyDatacollectionWithChildrenPlatformsAndBrowsers(): void
{
$collection = $this->getMockBuilder(DataCollection::class)
->disableOriginalConstructor()
->onlyMethods(['getDivisions', 'getDefaultProperties', 'getDevice', 'getPlatform', 'getEngine', 'getBrowser'])
->getMock();
$defaultProperties = $this->getMockBuilder(UserAgent::class)
->disableOriginalConstructor()
->onlyMethods(['getUserAgent', 'getProperties'])
->getMock();
$defaultProperties
->expects(static::exactly(3))
->method('getProperties')
->willReturn(['avd' => 'xyz']);
$defaultProperties
->expects(static::once())
->method('getUserAgent')
->willReturn('Defaultproperties');
$coreDivision = $this->getMockBuilder(Division::class)
->disableOriginalConstructor()
->onlyMethods(['getUserAgents'])
->getMock();
$coreDivision
->expects(static::once())
->method('getUserAgents')
->willReturn([0 => $defaultProperties]);
$browser = $this->getMockBuilder(Browser::class)
->disableOriginalConstructor()
->onlyMethods(['getProperties', 'getType'])
->getMock();
$browser
->expects(static::once())
->method('getProperties')
->willReturn(['avd' => 'fgh']);
$browser
->expects(static::once())
->method('getType')
->willReturn('browser');
$collection
->expects(static::once())
->method('getDefaultProperties')
->willReturn($coreDivision);
$collection
->expects(static::never())
->method('getDevice');
$collection
->expects(static::never())
->method('getPlatform');
$collection
->expects(static::never())
->method('getEngine');
$collection
->expects(static::once())
->method('getBrowser')
->with('def')
->willReturn($browser);
$useragent = $this->getMockBuilder(UserAgent::class)
->disableOriginalConstructor()
->onlyMethods(['getUserAgent', 'getProperties', 'getChildren', 'getPlatform'])
->getMock();
$useragent
->expects(static::once())
->method('getUserAgent')
->willReturn('abc');
$useragent
->expects(static::once())
->method('getProperties')
->willReturn([
'Parent' => 'Defaultproperties',
'Version' => '1.0',
'MajorVer' => 1,
'Browser' => 'xyz',
]);
$useragent
->expects(static::once())
->method('getChildren')
->willReturn([
0 => [
'match' => 'abc*#DEVICE#',
'browser' => 'def',
'properties' => ['Browser' => 'xyza'],
],
]);
$useragent
->expects(static::once())
->method('getPlatform')
->willReturn(null);
$division = $this->getMockBuilder(Division::class)
->disableOriginalConstructor()
->onlyMethods(['getUserAgents', 'getFileName'])
->getMock();
$division
->expects(static::once())
->method('getUserAgents')
->willReturn([0 => $useragent]);
$division
->expects(static::once())
->method('getFileName')
->willReturn('tests/test.json');
$property = new ReflectionProperty($this->object, 'collection');
$property->setValue($this->object, $collection);
assert($division instanceof Division);
$this->object->expand($division, 'TestDivision');
} | tests pattern id generation on a not empty data collection with children, platforms and devices
@throws ReflectionException
@throws UnexpectedValueException
@throws OutOfBoundsException
@throws ParentNotDefinedException
@throws InvalidParentException
@throws DuplicateDataException | testPatternIdCollectionOnNotEmptyDatacollectionWithChildrenPlatformsAndBrowsers | php | browscap/browscap | tests/BrowscapTest/Data/ExpanderTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Data/ExpanderTest.php | MIT |
public function testPatternIdCollectionOnNotEmptyDatacollectionWithChildrenPlatformsAndBrowsers2(): void
{
$collection = $this->getMockBuilder(DataCollection::class)
->disableOriginalConstructor()
->onlyMethods(['getDivisions', 'getDefaultProperties', 'getDevice', 'getPlatform', 'getEngine', 'getBrowser'])
->getMock();
$defaultProperties = $this->getMockBuilder(UserAgent::class)
->disableOriginalConstructor()
->onlyMethods(['getUserAgent', 'getProperties'])
->getMock();
$defaultProperties
->expects(static::exactly(3))
->method('getProperties')
->willReturn(['avd' => 'xyz']);
$defaultProperties
->expects(static::once())
->method('getUserAgent')
->willReturn('Defaultproperties');
$coreDivision = $this->getMockBuilder(Division::class)
->disableOriginalConstructor()
->onlyMethods(['getUserAgents'])
->getMock();
$coreDivision
->expects(static::once())
->method('getUserAgents')
->willReturn([0 => $defaultProperties]);
$browser = $this->getMockBuilder(Browser::class)
->disableOriginalConstructor()
->onlyMethods(['getProperties', 'getType'])
->getMock();
$browser
->expects(static::once())
->method('getProperties')
->willReturn(['avd' => 'hjk']);
$browser
->expects(static::once())
->method('getType')
->willReturn('browser');
$engine = $this->getMockBuilder(Engine::class)
->disableOriginalConstructor()
->getMock();
$engine
->expects(static::once())
->method('getProperties')
->willReturn(['RenderingEngine_Name' => 'unknown engine']);
$collection
->expects(static::once())
->method('getDefaultProperties')
->willReturn($coreDivision);
$collection
->expects(static::never())
->method('getDevice');
$collection
->expects(static::never())
->method('getPlatform');
$collection
->expects(static::once())
->method('getEngine')
->with('Engine_1')
->willReturn($engine);
$collection
->expects(static::once())
->method('getBrowser')
->with('def')
->willReturn($browser);
$useragent = $this->getMockBuilder(UserAgent::class)
->disableOriginalConstructor()
->onlyMethods(['getUserAgent', 'getProperties', 'getChildren', 'getPlatform'])
->getMock();
$useragent
->expects(static::once())
->method('getUserAgent')
->willReturn('abc');
$useragent
->expects(static::once())
->method('getProperties')
->willReturn([
'Parent' => 'Defaultproperties',
'Version' => '1.0',
'MajorVer' => 1,
'Browser' => 'xyz',
]);
$useragent
->expects(static::once())
->method('getChildren')
->willReturn([
0 => [
'match' => 'abc*#DEVICE#',
'browser' => 'def',
'engine' => 'Engine_1',
'properties' => ['Browser' => 'xyza'],
],
]);
$useragent
->expects(static::once())
->method('getPlatform')
->willReturn(null);
$division = $this->getMockBuilder(Division::class)
->disableOriginalConstructor()
->onlyMethods(['getUserAgents', 'getFileName'])
->getMock();
$division
->expects(static::once())
->method('getUserAgents')
->willReturn([0 => $useragent]);
$division
->expects(static::once())
->method('getFileName')
->willReturn('tests/test.json');
$property = new ReflectionProperty($this->object, 'collection');
$property->setValue($this->object, $collection);
assert($division instanceof Division);
$this->object->expand($division, 'TestDivision');
} | tests pattern id generation on a not empty data collection with children, platforms and devices
@throws ReflectionException
@throws UnexpectedValueException
@throws OutOfBoundsException
@throws ParentNotDefinedException
@throws InvalidParentException
@throws DuplicateDataException | testPatternIdCollectionOnNotEmptyDatacollectionWithChildrenPlatformsAndBrowsers2 | php | browscap/browscap | tests/BrowscapTest/Data/ExpanderTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Data/ExpanderTest.php | MIT |
public function testGetter(): void
{
$match = 'TestMatchName';
$properties = ['Platform' => 'def'];
$object = new Platform($match, $properties, true, false);
static::assertSame($match, $object->getMatch());
static::assertSame($properties, $object->getProperties());
static::assertTrue($object->isLite());
static::assertFalse($object->isStandard());
} | tests setter and getter for the match property
@throws ExpectationFailedException | testGetter | php | browscap/browscap | tests/BrowscapTest/Data/PlatformTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Data/PlatformTest.php | MIT |
public static function propertyNameTypeDataProvider(): array
{
return [
['Comment', PropertyHolder::TYPE_STRING],
['Browser', PropertyHolder::TYPE_STRING],
['Platform', PropertyHolder::TYPE_STRING],
['Platform_Description', PropertyHolder::TYPE_STRING],
['Device_Name', PropertyHolder::TYPE_STRING],
['Device_Maker', PropertyHolder::TYPE_STRING],
['RenderingEngine_Name', PropertyHolder::TYPE_STRING],
['RenderingEngine_Description', PropertyHolder::TYPE_STRING],
['Parent', PropertyHolder::TYPE_STRING],
['Platform_Version', PropertyHolder::TYPE_GENERIC],
['RenderingEngine_Version', PropertyHolder::TYPE_GENERIC],
['Version', PropertyHolder::TYPE_NUMBER],
['MajorVer', PropertyHolder::TYPE_NUMBER],
['MinorVer', PropertyHolder::TYPE_NUMBER],
['CssVersion', PropertyHolder::TYPE_NUMBER],
['AolVersion', PropertyHolder::TYPE_NUMBER],
['Alpha', PropertyHolder::TYPE_BOOLEAN],
['Beta', PropertyHolder::TYPE_BOOLEAN],
['Win16', PropertyHolder::TYPE_BOOLEAN],
['Win32', PropertyHolder::TYPE_BOOLEAN],
['Win64', PropertyHolder::TYPE_BOOLEAN],
['Frames', PropertyHolder::TYPE_BOOLEAN],
['IFrames', PropertyHolder::TYPE_BOOLEAN],
['Tables', PropertyHolder::TYPE_BOOLEAN],
['Cookies', PropertyHolder::TYPE_BOOLEAN],
['BackgroundSounds', PropertyHolder::TYPE_BOOLEAN],
['JavaScript', PropertyHolder::TYPE_BOOLEAN],
['VBScript', PropertyHolder::TYPE_BOOLEAN],
['JavaApplets', PropertyHolder::TYPE_BOOLEAN],
['ActiveXControls', PropertyHolder::TYPE_BOOLEAN],
['isMobileDevice', PropertyHolder::TYPE_BOOLEAN],
['isSyndicationReader', PropertyHolder::TYPE_BOOLEAN],
['isFake', PropertyHolder::TYPE_BOOLEAN],
['isAnonymized', PropertyHolder::TYPE_BOOLEAN],
['isModified', PropertyHolder::TYPE_BOOLEAN],
['Crawler', PropertyHolder::TYPE_BOOLEAN],
['Browser_Type', PropertyHolder::TYPE_STRING],
['Device_Type', PropertyHolder::TYPE_STRING],
['Device_Pointing_Method', PropertyHolder::TYPE_IN_ARRAY],
['PatternId', PropertyHolder::TYPE_STRING],
['PropertyName', PropertyHolder::TYPE_STRING],
];
} | Data Provider for the test testGetPropertyType
@return array<array<string>>
@throws void | propertyNameTypeDataProvider | php | browscap/browscap | tests/BrowscapTest/Data/PropertyHolderTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Data/PropertyHolderTest.php | MIT |
public function testGetPropertyType(string $propertyName, string $expectedType): void
{
$actualType = $this->object->getPropertyType($propertyName);
static::assertSame($expectedType, $actualType, sprintf('Property %s should be %s (was %s)', $propertyName, $expectedType, $actualType));
} | @throws ExpectationFailedException
@throws InvalidArgumentException
@dataProvider propertyNameTypeDataProvider | testGetPropertyType | php | browscap/browscap | tests/BrowscapTest/Data/PropertyHolderTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Data/PropertyHolderTest.php | MIT |
public static function litePropertiesDataProvider(): array
{
return [
['Comment', true],
['Browser', true],
['Platform', true],
['Platform_Description', false],
['Device_Name', false],
['Device_Maker', false],
['RenderingEngine_Name', false],
['RenderingEngine_Description', false],
['Parent', true],
['Platform_Version', false],
['RenderingEngine_Version', false],
['Version', true],
['MajorVer', false],
['MinorVer', false],
['CssVersion', false],
['AolVersion', false],
['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', true],
['isSyndicationReader', false],
['isFake', false],
['isAnonymized', false],
['isModified', false],
['Crawler', false],
['Browser_Type', false],
['Device_Type', true],
['Device_Pointing_Method', false],
['Browser_Maker', false],
['isTablet', true],
['PatternId', false],
];
} | Data Provider for the test testIsLiteModeProperty
@return array<int, array<int, bool|string>>
@throws void | litePropertiesDataProvider | php | browscap/browscap | tests/BrowscapTest/Data/PropertyHolderTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Data/PropertyHolderTest.php | MIT |
public function testIsLiteModePropertyWithWriter(): void
{
$mockWriter = $this->getMockBuilder(IniWriter::class)
->disableOriginalConstructor()
->onlyMethods(['getType'])
->getMock();
$mockWriter
->expects(static::once())
->method('getType')
->willReturn(WriterInterface::TYPE_INI);
static::assertTrue($this->object->isLiteModeProperty('PatternId', $mockWriter));
} | tests detecting a standard mode property
@throws ExpectationFailedException | testIsLiteModePropertyWithWriter | php | browscap/browscap | tests/BrowscapTest/Data/PropertyHolderTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Data/PropertyHolderTest.php | MIT |
public static function standardPropertiesDataProvider(): array
{
return [
['Comment', false],
['Browser', false],
['Platform', false],
['Platform_Description', false],
['Device_Name', false],
['Device_Maker', false],
['RenderingEngine_Name', false],
['RenderingEngine_Description', false],
['Parent', false],
['Platform_Version', false],
['RenderingEngine_Version', false],
['Version', false],
['MajorVer', true],
['MinorVer', true],
['CssVersion', false],
['AolVersion', false],
['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],
['isSyndicationReader', false],
['isFake', false],
['isAnonymized', false],
['isModified', false],
['Crawler', true],
['Browser_Type', false],
['Device_Type', false],
['Device_Pointing_Method', true],
['Browser_Maker', true],
['isTablet', false],
['PatternId', false],
];
} | Data Provider for the test testIsStandardModeProperty
@return array<int, array<int, bool|string>>
@throws void | standardPropertiesDataProvider | php | browscap/browscap | tests/BrowscapTest/Data/PropertyHolderTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Data/PropertyHolderTest.php | MIT |
public function testIsLiteModePropertyWithIniWriter(): void
{
$mockWriter = $this->getMockBuilder(IniWriter::class)
->disableOriginalConstructor()
->onlyMethods(['getType'])
->getMock();
$mockWriter
->expects(static::once())
->method('getType')
->willReturn(WriterInterface::TYPE_INI);
static::assertTrue($this->object->isLiteModeProperty('PatternId', $mockWriter));
} | tests detecting a standard mode property
@throws ExpectationFailedException | testIsLiteModePropertyWithIniWriter | php | browscap/browscap | tests/BrowscapTest/Data/PropertyHolderTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Data/PropertyHolderTest.php | MIT |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.