Ejemplo n.º 1
0
 /**
  * @param float $finalPrice
  * @param float $specialPrice
  * @param int $callsNumber
  * @param bool $dateInInterval
  * @param float $expected
  *
  * @covers \Magento\Bundle\Model\Product\Price::calculateSpecialPrice
  * @covers \Magento\Bundle\Model\Product\Price::__construct
  * @dataProvider calculateSpecialPrice
  */
 public function testCalculateSpecialPrice($finalPrice, $specialPrice, $callsNumber, $dateInInterval, $expected)
 {
     $this->localeDateMock->expects($this->exactly($callsNumber))->method('isScopeDateInInterval')->will($this->returnValue($dateInInterval));
     $this->storeManagerMock->expects($this->any())->method('getStore')->will($this->returnValue($this->storeMock));
     $this->storeMock->expects($this->any())->method('roundPrice')->will($this->returnArgument(0));
     $this->assertEquals($expected, $this->model->calculateSpecialPrice($finalPrice, $specialPrice, date('Y-m-d'), date('Y-m-d')));
 }
Ejemplo n.º 2
0
 public function testGetTierPrice()
 {
     $product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Catalog\\Model\\Product');
     $product->load(3);
     // fixture
     // Note that this is really not the "tier price" but the "tier discount percentage"
     // so it is expected to be increasing instead of decreasing
     $this->assertEquals(8.0, $this->_model->getTierPrice(2, $product));
     $this->assertEquals(20.0, $this->_model->getTierPrice(3, $product));
     $this->assertEquals(20.0, $this->_model->getTierPrice(4, $product));
     $this->assertEquals(30.0, $this->_model->getTierPrice(5, $product));
 }
Ejemplo n.º 3
0
 public function testGetTierPrice()
 {
     /** @var \Magento\Catalog\Api\ProductRepositoryInterface $productRepository */
     $productRepository = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Catalog\\Api\\ProductRepositoryInterface');
     $product = $productRepository->get('bundle-product');
     // fixture
     // Note that this is really not the "tier price" but the "tier discount percentage"
     // so it is expected to be increasing instead of decreasing
     $this->assertEquals(8.0, $this->_model->getTierPrice(2, $product));
     $this->assertEquals(20.0, $this->_model->getTierPrice(3, $product));
     $this->assertEquals(20.0, $this->_model->getTierPrice(4, $product));
     $this->assertEquals(30.0, $this->_model->getTierPrice(5, $product));
 }
Ejemplo n.º 4
0
 public function testGetTotalBundleItemsPriceWithNoItems()
 {
     $storeId = 1;
     $dataObjectMock = $this->getMockBuilder('Magento\\Framework\\DataObject')->setMethods(['getValue'])->disableOriginalConstructor()->getMock();
     $productMock = $this->getMockBuilder('Magento\\Catalog\\Model\\Product')->disableOriginalConstructor()->getMock();
     $productTypeMock = $this->getMockBuilder('Magento\\Bundle\\Model\\Product\\Type')->disableOriginalConstructor()->getMock();
     $selectionsMock = $this->getMockBuilder('Magento\\Bundle\\Model\\ResourceModel\\Selection\\Collection')->disableOriginalConstructor()->getMock();
     $productMock->expects($this->once())->method('hasCustomOptions')->willReturn(true);
     $productMock->expects($this->once())->method('getCustomOption')->with('bundle_selection_ids')->willReturn($dataObjectMock);
     $productMock->expects($this->once())->method('getTypeInstance')->willReturn($productTypeMock);
     $productMock->expects($this->once())->method('getStoreId')->willReturn($storeId);
     $dataObjectMock->expects($this->once())->method('getValue')->willReturn('a:1:{i:0;s:1:"1";}');
     $productTypeMock->expects($this->once())->method('getSelectionsByIds')->with([1], $productMock)->willReturn($selectionsMock);
     $selectionsMock->expects($this->once())->method('addTierPriceData')->willReturnSelf();
     $selectionsMock->expects($this->once())->method('getItems')->willReturn([]);
     $this->eventManagerMock->expects($this->once())->method('dispatch')->with('prepare_catalog_product_collection_prices', ['collection' => $selectionsMock, 'store_id' => $storeId])->willReturnSelf();
     $this->assertEquals(0, $this->model->getTotalBundleItemsPrice($productMock));
 }