setFormatter() public méthode

public setFormatter ( Browscap\Formatter\FormatterInterface $formatter ) : Browscap\Writer\WriterInterface
$formatter Browscap\Formatter\FormatterInterface
Résultat Browscap\Writer\WriterInterface
Exemple #1
0
 /**
  * tests rendering the body of one section
  *
  * @group writer
  * @group sourcetest
  */
 public function testRenderSectionBodyIfNotSilent()
 {
     $this->object->setSilent(false);
     $section = ['Test' => 1, 'isTest' => true, 'abc' => 'bcd'];
     $expectedAgents = [0 => ['properties' => ['Test' => 'abc', 'abc' => true, 'alpha' => true]]];
     $division = $this->getMockBuilder(\Browscap\Data\Division::class)->disableOriginalConstructor()->setMethods(['getUserAgents'])->getMock();
     $division->expects(self::once())->method('getUserAgents')->will(self::returnValue($expectedAgents));
     $collection = $this->getMockBuilder(\Browscap\Data\DataCollection::class)->disableOriginalConstructor()->setMethods(['getDefaultProperties'])->getMock();
     $collection->expects(self::once())->method('getDefaultProperties')->will(self::returnValue($division));
     $mockFormatter = $this->getMockBuilder(\Browscap\Formatter\CsvFormatter::class)->disableOriginalConstructor()->setMethods(['formatPropertyValue'])->getMock();
     $mockFormatter->expects(self::exactly(3))->method('formatPropertyValue')->will(self::returnArgument(0));
     self::assertSame($this->object, $this->object->setFormatter($mockFormatter));
     $mockFilter = $this->getMockBuilder(\Browscap\Filter\FullFilter::class)->disableOriginalConstructor()->setMethods(['isOutputProperty'])->getMock();
     $map = [['Test', $this->object, true], ['isTest', $this->object, false], ['abc', $this->object, true], ['alpha', $this->object, true]];
     $mockFilter->expects(self::exactly(7))->method('isOutputProperty')->will(self::returnValueMap($map));
     self::assertSame($this->object, $this->object->setFilter($mockFilter));
     $logger = $this->createMock(\Monolog\Logger::class);
     $this->object->setLogger($logger);
     self::assertSame($this->object, $this->object->renderSectionBody($section, $collection));
     self::assertSame('1,bcd,' . PHP_EOL, file_get_contents($this->file));
 }
 /**
  * tests rendering the body of one section
  *
  * @group writer
  * @group sourcetest
  */
 public function testRenderSectionBodyIfNotSilent()
 {
     $this->object->setSilent(false);
     $section = array('Test' => 1, 'isTest' => true, 'abc' => 'bcd');
     $expectedAgents = array(0 => array('properties' => array('Test' => 'abc', 'abc' => true, 'alpha' => true)));
     $mockDivision = $this->getMock('\\Browscap\\Data\\Division', array('getUserAgents'), array(), '', false);
     $mockDivision->expects(self::once())->method('getUserAgents')->will(self::returnValue($expectedAgents));
     $mockCollection = $this->getMock('\\Browscap\\Data\\DataCollection', array('getDefaultProperties'), array(), '', false);
     $mockCollection->expects(self::once())->method('getDefaultProperties')->will(self::returnValue($mockDivision));
     $mockFormatter = $this->getMock('\\Browscap\\Formatter\\CsvFormatter', array('formatPropertyValue'), array(), '', false);
     $mockFormatter->expects(self::exactly(3))->method('formatPropertyValue')->will(self::returnArgument(0));
     self::assertSame($this->object, $this->object->setFormatter($mockFormatter));
     $mockFilter = $this->getMock('\\Browscap\\Filter\\FullFilter', array('isOutputProperty'), array(), '', false);
     $map = array(array('Test', $this->object, true), array('isTest', $this->object, false), array('abc', $this->object, true), array('alpha', $this->object, true));
     $mockFilter->expects(self::exactly(7))->method('isOutputProperty')->will(self::returnValueMap($map));
     self::assertSame($this->object, $this->object->setFilter($mockFilter));
     $mockLogger = $this->getMock('\\Monolog\\Logger', array(), array(), '', false);
     $this->object->setLogger($mockLogger);
     self::assertSame($this->object, $this->object->renderSectionBody($section, $mockCollection));
     self::assertSame('1,bcd,' . PHP_EOL, file_get_contents($this->file));
 }