/** * @magentoDataFixture Magento/Sales/_files/order.php * @magentoDataFixture Magento/Sales/_files/report_bestsellers.php */ public function testGetItems() { $expectedResult = array(1 => 2); $actualResult = array(); /** @var \Magento\Reports\Model\Item $reportItem */ foreach ($this->_collection->getItems() as $reportItem) { $actualResult[$reportItem->getData('product_id')] = $reportItem->getData('qty_ordered'); } $this->assertEquals($expectedResult, $actualResult); }
/** * @dataProvider tableForPeriodDataProvider * * @param $period * @param $expectedTable * @param $dateFrom * @param $dateTo */ public function testTableSelection($period, $expectedTable, $dateFrom, $dateTo) { $dbTableName = $this->_collection->getTable($expectedTable); $this->_collection->setPeriod($period); $this->_collection->setDateRange($dateFrom, $dateTo); $this->_collection->load(); $from = $this->_collection->getSelect()->getPart('from'); $this->assertArrayHasKey($dbTableName, $from); $this->assertArrayHasKey('tableName', $from[$dbTableName]); $actualTable = $from[$dbTableName]['tableName']; $this->assertEquals($dbTableName, $actualTable); }