run() public static method

Entry point for generating builds for a specified version
public static run ( string $version, string $resourceFolder, Psr\Log\LoggerInterface $logger, WriterCollection $writerCollection, CollectionCreator $collectionCreator )
$version string
$resourceFolder string
$logger Psr\Log\LoggerInterface
$writerCollection Browscap\Writer\WriterCollection
$collectionCreator Browscap\Helper\CollectionCreator
Beispiel #1
0
 /**
  * tests running a build
  *
  * @group generator
  * @group sourcetest
  */
 public function testRun()
 {
     $logger = $this->createMock(\Monolog\Logger::class);
     $writerCollection = $this->getMockBuilder(\Browscap\Writer\WriterCollection::class)->disableOriginalConstructor()->setMethods(['fileStart', 'renderHeader', 'renderAllDivisionsHeader', 'renderDivisionFooter', 'renderSectionHeader', 'renderSectionBody', 'fileEnd'])->getMock();
     $writerCollection->expects(self::once())->method('fileStart')->will(self::returnSelf());
     $writerCollection->expects(self::once())->method('fileEnd')->will(self::returnSelf());
     $writerCollection->expects(self::once())->method('renderHeader')->will(self::returnSelf());
     $writerCollection->expects(self::once())->method('renderAllDivisionsHeader')->will(self::returnSelf());
     $writerCollection->expects(self::any())->method('renderDivisionFooter')->will(self::returnSelf());
     $writerCollection->expects(self::any())->method('renderSectionHeader')->will(self::returnSelf());
     $writerCollection->expects(self::any())->method('renderSectionBody')->will(self::returnSelf());
     $division = $this->getMockBuilder(\Browscap\Data\Division::class)->disableOriginalConstructor()->setMethods(['getUserAgents', 'getVersions'])->getMock();
     $division->expects(self::exactly(4))->method('getUserAgents')->will(self::returnValue([0 => ['properties' => ['Parent' => 'DefaultProperties', 'Browser' => 'xyz', 'Version' => '1.0', 'MajorBer' => '1'], 'userAgent' => 'abc']]));
     $division->expects(self::once())->method('getVersions')->will(self::returnValue([2]));
     $collection = $this->getMockBuilder(\Browscap\Data\DataCollection::class)->disableOriginalConstructor()->setMethods(['getGenerationDate', 'getDefaultProperties', 'getDefaultBrowser', 'getDivisions', 'checkProperty'])->getMock();
     $collection->expects(self::once())->method('getGenerationDate')->will(self::returnValue(new \DateTime()));
     $collection->expects(self::exactly(2))->method('getDefaultProperties')->will(self::returnValue($division));
     $collection->expects(self::once())->method('getDefaultBrowser')->will(self::returnValue($division));
     $collection->expects(self::once())->method('getDivisions')->will(self::returnValue([$division]));
     $collection->expects(self::once())->method('checkProperty')->will(self::returnValue(true));
     $collectionCreator = $this->getMockBuilder(\Browscap\Helper\CollectionCreator::class)->disableOriginalConstructor()->setMethods(['setLogger', 'getLogger', 'createDataCollection'])->getMock();
     $collectionCreator->expects(self::once())->method('setLogger')->will(self::returnSelf());
     $collectionCreator->expects(self::never())->method('getLogger')->will(self::returnValue($logger));
     $collectionCreator->expects(self::once())->method('createDataCollection')->will(self::returnValue($collection));
     BuildHelper::run('test', '.', $logger, $writerCollection, $collectionCreator);
 }
 /**
  * tests running a build
  *
  * @group generator
  * @group sourcetest
  */
 public function testRun()
 {
     $logger = $this->getMock('\\Monolog\\Logger', array(), array(), '', false);
     $writerCollection = $this->getMock('\\Browscap\\Writer\\WriterCollection', array('fileStart', 'fileEnd', 'renderHeader', 'renderAllDivisionsHeader', 'renderDivisionFooter', 'renderSectionHeader', 'renderSectionBody'), array(), '', false);
     $writerCollection->expects(self::once())->method('fileStart')->will(self::returnSelf());
     $writerCollection->expects(self::once())->method('fileEnd')->will(self::returnSelf());
     $writerCollection->expects(self::once())->method('renderHeader')->will(self::returnSelf());
     $writerCollection->expects(self::once())->method('renderAllDivisionsHeader')->will(self::returnSelf());
     $writerCollection->expects(self::any())->method('renderDivisionFooter')->will(self::returnSelf());
     $writerCollection->expects(self::any())->method('renderSectionHeader')->will(self::returnSelf());
     $writerCollection->expects(self::any())->method('renderSectionBody')->will(self::returnSelf());
     $mockDivision = $this->getMock('\\Browscap\\Data\\Division', array('getUserAgents', 'getVersions'), array(), '', false);
     $mockDivision->expects(self::exactly(4))->method('getUserAgents')->will(self::returnValue(array(0 => array('properties' => array('Parent' => 'DefaultProperties', 'Browser' => 'xyz', 'Version' => '1.0', 'MajorBer' => '1'), 'userAgent' => 'abc'))));
     $mockDivision->expects(self::once())->method('getVersions')->will(self::returnValue(array(2)));
     $mockCollection = $this->getMock('\\Browscap\\Data\\DataCollection', array('getGenerationDate', 'getDefaultProperties', 'getDefaultBrowser', 'getDivisions', 'checkProperty'), array(), '', false);
     $mockCollection->expects(self::once())->method('getGenerationDate')->will(self::returnValue(new \DateTime()));
     $mockCollection->expects(self::exactly(2))->method('getDefaultProperties')->will(self::returnValue($mockDivision));
     $mockCollection->expects(self::once())->method('getDefaultBrowser')->will(self::returnValue($mockDivision));
     $mockCollection->expects(self::once())->method('getDivisions')->will(self::returnValue(array($mockDivision)));
     $mockCollection->expects(self::once())->method('checkProperty')->will(self::returnValue(true));
     $collectionCreator = $this->getMock('\\Browscap\\Helper\\CollectionCreator', array('setLogger', 'getLogger', 'createDataCollection'), array(), '', false);
     $collectionCreator->expects(self::once())->method('setLogger')->will(self::returnSelf());
     $collectionCreator->expects(self::never())->method('getLogger')->will(self::returnValue($logger));
     $collectionCreator->expects(self::once())->method('createDataCollection')->will(self::returnValue($mockCollection));
     BuildHelper::run('test', '.', $logger, $writerCollection, $collectionCreator);
 }
 /**
  * runs the build
  *
  * @param string $version
  *
  * @return \Browscap\Generator\AbstractBuildGenerator
  */
 protected function build($version)
 {
     Helper\BuildHelper::run($version, $this->resourceFolder, $this->getLogger(), $this->getWriterCollection(), $this->getCollectionCreator());
     return $this;
 }