public function testConvert() { $total = []; $storeId = 1; $testedTotalMock = $this->getMock('Magento\\Quote\\Model\\Quote\\Address\\Total', ['setData', 'getCode'], [], '', false); $expected = ['my_total_type' => $testedTotalMock]; $this->totalMock->expects($this->once())->method('setData')->with([])->willReturnSelf(); $this->quoteMock->expects($this->once())->method('getStoreId')->willReturn($storeId); $this->totalFactoryMock->expects($this->once())->method('create')->willReturn($this->totalMock); $this->collectionListMock->expects($this->once())->method('getCollectors')->with($storeId)->willReturn([$this->collectorMock]); $this->collectorMock->expects($this->once())->method('fetch')->with($this->quoteMock, $this->totalMock)->willReturn($testedTotalMock); $testedTotalMock->expects($this->never())->method('setData'); $testedTotalMock->expects($this->any())->method('getCode')->willReturn('my_total_type'); $this->assertEquals($expected, $this->model->fetch($this->quoteMock, $total)); }
/** * Get address totals as array * * @return array */ public function getTotals() { $totalsData = array_merge($this->getData(), ['address_quote_items' => $this->getAllItems()]); $totals = $this->totalsReader->fetch($this->getQuote(), $totalsData); foreach ($totals as $total) { $this->addTotal($total); } return $this->_totals; }