priceCollection = $this->createMock(\Magento\Framework\Pricing\Price\Collection::class); $this->adjustmentCollection = $this->createMock(\Magento\Framework\Pricing\Adjustment\Collection::class); $this->model = new Base($this->priceCollection, $this->adjustmentCollection); } /** * test method getPrices() */ public function testGetPrices() { $this->assertEquals($this->priceCollection, $this->model->getPrices()); } /** * @param $entryParams * @param $createCount * @dataProvider providerGetPrice */ public function testGetPrice($entryParams, $createCount) { $priceCode = current(array_values(reset($entryParams))); $this->priceCollection ->expects($this->exactly($createCount)) ->method('get') ->with($this->equalTo($priceCode)) ->will($this->returnValue('basePrice')); foreach ($entryParams as $params) { list($priceCode) = array_values($params); $this->assertEquals('basePrice', $this->model->getPrice($priceCode)); } } /** * Data provider for testGetPrice * * @return array */ public function providerGetPrice() { return [ 'case with empty quantity' => [ 'entryParams' => [ ['priceCode' => 'testCode'], ], 'createCount' => 1, ], 'case with existing price' => [ 'entryParams' => [ ['priceCode' => 'testCode'], ['priceCode' => 'testCode'], ], 'createCount' => 2, ], 'case with quantity' => [ 'entryParams' => [ ['priceCode' => 'testCode'], ], 'createCount' => 1, ], ]; } /** * @covers \Magento\Framework\Pricing\PriceInfo\Base::getAdjustments */ public function testGetAdjustments() { $this->adjustmentCollection->expects($this->once())->method('getItems')->will($this->returnValue('result')); $this->assertEquals('result', $this->model->getAdjustments()); } /** * @covers \Magento\Framework\Pricing\PriceInfo\Base::getAdjustment */ public function testGetAdjustment() { $this->adjustmentCollection->expects($this->any())->method('getItemByCode') ->with('test1') ->will($this->returnValue('adjustment')); $this->assertEquals('adjustment', $this->model->getAdjustment('test1')); } }