public function renderSectionBody(array $section, DataCollection $collection, array $sections = [], $sectionName = '') { if ($this->isSilent()) { return $this; } $division = $collection->getDefaultProperties(); $ua = $division->getUserAgents(); $defaultproperties = $ua[0]['properties']; $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->getFilter()->isOutputProperty($property, $this); } if (!$this->outputProperties[$property]) { continue; } fputs($this->file, '<item name="' . $this->getFormatter()->formatPropertyName($property) . '" value="' . $this->getFormatter()->formatPropertyValue($section[$property], $property) . '"/>' . PHP_EOL); } return $this; }
/** * tests rendering the body of one section * * @group writer * @group sourcetest */ public function testRenderSectionBodyIfSilent() { $this->object->setSilent(true); $section = array('Test' => 1, 'isTest' => true, 'abc' => 'bcd'); $mockCollection = $this->getMock('\\Browscap\\Data\\DataCollection', array(), array(), '', false); self::assertSame($this->object, $this->object->renderSectionBody($section, $mockCollection)); self::assertSame('', file_get_contents($this->file)); }