Beispiel #1
0
 /**
  * @covers \Magento\Catalog\Pricing\Price\TierPrice::__construct
  * @covers \Magento\Catalog\Pricing\Price\TierPrice::getTierPriceList
  * @covers \Magento\Catalog\Pricing\Price\TierPrice::getStoredTierPrices
  * @covers \Magento\Catalog\Pricing\Price\TierPrice::applyAdjustment
  * @covers \Magento\Catalog\Pricing\Price\TierPrice::getTierPriceCount
  * @covers \Magento\Catalog\Pricing\Price\TierPrice::filterTierPrices
  * @covers \Magento\Catalog\Pricing\Price\TierPrice::getBasePrice
  * @dataProvider providerForGetterTierPriceList
  */
 public function testGetterTierPriceList($tierPrices, $basePrice, $expectedResult)
 {
     $this->product->setData(TierPrice::PRICE_CODE, $tierPrices);
     $price = $this->getMock('Magento\\Framework\\Pricing\\Price\\PriceInterface', [], [], '', false);
     $price->expects($this->any())->method('getValue')->will($this->returnValue($basePrice));
     $this->priceInfo->expects($this->atLeastOnce())->method('getPrice')->will($this->returnValue($price));
     $this->calculator->expects($this->atLeastOnce())->method('getAmount')->will($this->returnArgument(0));
     $this->assertEquals($expectedResult, $this->model->getTierPriceList());
     $this->assertEquals(count($expectedResult), $this->model->getTierPriceCount());
 }
 /**
  * @covers \Magento\Catalog\Pricing\Price\TierPrice::__construct
  * @covers \Magento\Catalog\Pricing\Price\TierPrice::getTierPriceList
  * @covers \Magento\Catalog\Pricing\Price\TierPrice::getStoredTierPrices
  * @covers \Magento\Catalog\Pricing\Price\TierPrice::applyAdjustment
  * @covers \Magento\Catalog\Pricing\Price\TierPrice::getTierPriceCount
  * @covers \Magento\Catalog\Pricing\Price\TierPrice::filterTierPrices
  * @covers \Magento\Catalog\Pricing\Price\TierPrice::getBasePrice
  * @dataProvider providerForGetterTierPriceList
  */
 public function testGetterTierPriceList($tierPrices, $basePrice, $expectedResult)
 {
     $this->product->setData(TierPrice::PRICE_CODE, $tierPrices);
     $price = $this->getMock('Magento\\Framework\\Pricing\\Price\\PriceInterface', [], [], '', false);
     $price->expects($this->any())->method('getValue')->will($this->returnValue($basePrice));
     $this->calculator->expects($this->atLeastOnce())->method('getAmount')->will($this->returnArgument(0));
     $this->priceCurrencyMock->expects($this->any())->method('convertAndRound')->will($this->returnCallback(function ($arg) {
         return round(0.5 * $arg, 2);
     }));
     $group = $this->getMock('\\Magento\\Customer\\Model\\Data\\Group', [], [], '', false);
     $group->expects($this->any())->method('getId')->willReturn(GroupManagement::CUST_GROUP_ALL);
     $this->groupManagement->expects($this->any())->method('getAllCustomersGroup')->will($this->returnValue($group));
     $this->assertEquals($expectedResult, $this->model->getTierPriceList());
     $this->assertEquals(count($expectedResult), $this->model->getTierPriceCount());
     //Second call will get the cached value
     $this->assertEquals($expectedResult, $this->model->getTierPriceList());
     $this->assertEquals(count($expectedResult), $this->model->getTierPriceCount());
 }