/** * tests parsing an not empty data collection with children * * @group data * @group sourcetest */ public function testParseOnNotEmptyDatacollectionWithChildren() { $mockCollection = $this->getMock('\\Browscap\\Data\\DataCollection', array('getDivisions', 'getDefaultProperties'), array(), '', false); $mockCollection->expects(self::never())->method('getDivisions')->will(self::returnValue(array())); $mockDivision = $this->getMock('\\Browscap\\Data\\Division', array('getUserAgents'), array(), '', false); $mockDivision->expects(self::once())->method('getUserAgents')->will(self::returnValue(array(0 => array('properties' => array('avd' => 'xyz'))))); $mockCollection->expects(self::once())->method('getDefaultProperties')->will(self::returnValue($mockDivision)); $uaData = array(0 => array('userAgent' => 'abc', 'properties' => array('Parent' => 'Defaultproperties', 'Version' => '1.0', 'MajorVer' => 1, 'Browser' => 'xyz'), 'children' => array(0 => array('match' => 'abc*', 'properties' => array('Browser' => 'xyza'))))); $mockDivision = $this->getMock('\\Browscap\\Data\\Division', array('getUserAgents'), array(), '', false); $mockDivision->expects(self::once())->method('getUserAgents')->will(self::returnValue($uaData)); $this->object->setLogger($this->logger); self::assertSame($this->object, $this->object->setDataCollection($mockCollection)); $result = $this->object->expand($mockDivision, 'TestDivision'); self::assertInternalType('array', $result); self::assertCount(2, $result); }
/** * tests parsing an not empty data collection with children * * @group data * @group sourcetest */ public function testParseOnNotEmptyDatacollectionWithChildren() { $collection = $this->getMockBuilder(\Browscap\Data\DataCollection::class)->disableOriginalConstructor()->setMethods(['getDivisions', 'getDefaultProperties'])->getMock(); $collection->expects(self::never())->method('getDivisions')->will(self::returnValue([])); $division = $this->getMockBuilder(\Browscap\Data\Division::class)->disableOriginalConstructor()->setMethods(['getUserAgents'])->getMock(); $division->expects(self::once())->method('getUserAgents')->will(self::returnValue([0 => ['properties' => ['avd' => 'xyz']]])); $collection->expects(self::once())->method('getDefaultProperties')->will(self::returnValue($division)); $uaData = [0 => ['userAgent' => 'abc', 'properties' => ['Parent' => 'Defaultproperties', 'Version' => '1.0', 'MajorVer' => 1, 'Browser' => 'xyz'], 'children' => [0 => ['match' => 'abc*', 'properties' => ['Browser' => 'xyza']]]]]; $division = $this->getMockBuilder(\Browscap\Data\Division::class)->disableOriginalConstructor()->setMethods(['getUserAgents'])->getMock(); $division->expects(self::once())->method('getUserAgents')->will(self::returnValue($uaData)); $this->object->setLogger($this->logger); self::assertSame($this->object, $this->object->setDataCollection($collection)); $result = $this->object->expand($division, 'TestDivision'); self::assertInternalType('array', $result); self::assertCount(2, $result); }