public renderAllDivisionsHeader ( |
||
$collection | ||
return | Browscap\Writer\WriterInterface |
public function renderAllDivisionsHeader(DataCollection $collection)
{
$division = $collection->getDefaultProperties();
$ua = $division->getUserAgents();
if (empty($ua[0]['properties']) || !is_array($ua[0]['properties'])) {
return $this;
}
$defaultproperties = $ua[0]['properties'];
$properties = array_merge(['PropertyName', 'MasterParent', 'LiteMode', 'Parent'], array_keys($defaultproperties));
$values = [];
foreach ($properties as $property) {
if (!isset($this->outputProperties[$property])) {
$this->outputProperties[$property] = $this->getFilter()->isOutputProperty($property, $this);
}
if (!$this->outputProperties[$property]) {
continue;
}
$values[] = $this->getFormatter()->formatPropertyName($property);
}
fputs($this->file, implode(',', $values) . PHP_EOL);
return $this;
}
/** * tests rendering the header for all division * * @group writer * @group sourcetest */ public function testRenderAllDivisionsHeaderWithoutProperties() { $division = $this->getMockBuilder(\Browscap\Data\Division::class)->disableOriginalConstructor()->setMethods(['getUserAgents'])->getMock(); $division->expects(self::once())->method('getUserAgents')->will(self::returnValue([])); $collection = $this->getMockBuilder(\Browscap\Data\DataCollection::class)->disableOriginalConstructor()->setMethods(['getDefaultProperties'])->getMock(); $collection->expects(self::once())->method('getDefaultProperties')->will(self::returnValue($division)); self::assertSame($this->object, $this->object->renderAllDivisionsHeader($collection)); self::assertSame('', file_get_contents($this->file)); }