closes the Writer and the written File
public close ( ) : |
||
리턴 |
/** * tests rendering the version information * * @group writer * @group sourcetest */ public function testRenderVersion() { $version = 'test'; $mockCollection = $this->getMock('\\Browscap\\Data\\DataCollection', array('getGenerationDate'), array(), '', false); $mockCollection->expects(self::once())->method('getGenerationDate')->will(self::returnValue(new \DateTime())); $mockFilter = $this->getMock('\\Browscap\\Filter\\FullFilter', array('isOutput', 'getType'), array(), '', false); $mockFilter->expects(self::never())->method('isOutput')->will(self::returnValue(true)); $mockFilter->expects(self::once())->method('getType')->will(self::returnValue('Test')); $mockFormatter = $this->getMock('\\Browscap\\Formatter\\XmlFormatter', array('getType'), array(), '', false); $mockFormatter->expects(self::once())->method('getType')->will(self::returnValue('test')); $mockLogger = $this->getMock('\\Monolog\\Logger', array(), array(), '', false); $mockWriter = $this->getMock('\\Browscap\\Writer\\CsvWriter', array('getFilter', 'getFormatter', 'getLogger'), array($this->file), '', true); $mockWriter->expects(self::once())->method('getFilter')->will(self::returnValue($mockFilter)); $mockWriter->expects(self::once())->method('getFormatter')->will(self::returnValue($mockFormatter)); $mockWriter->expects(self::once())->method('getLogger')->will(self::returnValue($mockLogger)); self::assertSame($this->object, $this->object->addWriter($mockWriter)); self::assertSame($this->object, $this->object->renderVersion($version, $mockCollection)); self::assertSame($this->object, $this->object->close()); }
/** * tests rendering the version information * * @group writer * @group sourcetest */ public function testRenderVersion() { $version = 'test'; $collection = $this->getMockBuilder(\Browscap\Data\DataCollection::class)->disableOriginalConstructor()->setMethods(['getGenerationDate'])->getMock(); $collection->expects(self::once())->method('getGenerationDate')->will(self::returnValue(new \DateTime())); $mockFilter = $this->getMockBuilder(\Browscap\Filter\FullFilter::class)->disableOriginalConstructor()->setMethods(['isOutput', 'getType'])->getMock(); $mockFilter->expects(self::never())->method('isOutput')->will(self::returnValue(true)); $mockFilter->expects(self::once())->method('getType')->will(self::returnValue('Test')); $mockFormatter = $this->getMockBuilder(\Browscap\Formatter\XmlFormatter::class)->disableOriginalConstructor()->setMethods(['getType'])->getMock(); $mockFormatter->expects(self::once())->method('getType')->will(self::returnValue('test')); $logger = $this->createMock(\Monolog\Logger::class); $mockWriter = $this->getMockBuilder(\Browscap\Writer\CsvWriter::class)->setMethods(['getFilter', 'getFormatter', 'getLogger'])->setConstructorArgs([$this->file])->getMock(); $mockWriter->expects(self::once())->method('getFilter')->will(self::returnValue($mockFilter)); $mockWriter->expects(self::once())->method('getFormatter')->will(self::returnValue($mockFormatter)); $mockWriter->expects(self::once())->method('getLogger')->will(self::returnValue($logger)); self::assertSame($this->object, $this->object->addWriter($mockWriter)); self::assertSame($this->object, $this->object->renderVersion($version, $collection)); self::assertSame($this->object, $this->object->close()); }