예제 #1
0
 /**
  * test method getValue
  *
  * @dataProvider getValueDataProvider
  */
 public function testGetValue($specialPriceValue, $expectedResult)
 {
     $this->priceInfoMock->expects($this->once())->method('getPrices')->will($this->returnValue($this->prices));
     $this->regularPriceMock->expects($this->exactly(3))->method('getValue')->will($this->returnValue(100));
     $this->tearPriceMock->expects($this->exactly(2))->method('getValue')->will($this->returnValue(99));
     $this->specialPriceMock->expects($this->any())->method('getValue')->will($this->returnValue($specialPriceValue));
     $this->assertSame($expectedResult, $this->basePrice->getValue());
 }
예제 #2
0
 public function testGetValue()
 {
     $this->priceInfoMock->expects($this->once())->method('getPrice')->with($this->equalTo('regular_price'))->will($this->returnValue($this->regularPrice));
     $this->regularPrice->expects($this->once())->method('getValue')->will($this->returnValue(100));
     $this->productMock->expects($this->once())->method('getCustomerGroupId')->will($this->returnValue(null));
     $this->customerSessionMock->expects($this->once())->method('getCustomerGroupId')->will($this->returnValue(3));
     $this->productMock->expects($this->once())->method('getResource')->will($this->returnValue($this->productResourceMock));
     $this->productResourceMock->expects($this->once())->method('getAttribute')->with($this->equalTo('group_price'))->will($this->returnValue($this->attributeMock));
     $this->attributeMock->expects($this->once())->method('getBackend')->will($this->returnValue($this->backendMock));
     $this->backendMock->expects($this->once())->method('afterLoad')->with($this->equalTo($this->productMock))->will($this->returnValue($this->backendMock));
     $this->priceCurrencyMock->expects($this->never())->method('convertAndRound');
     $this->productMock->expects($this->once())->method('getData')->with($this->equalTo('group_price'), $this->equalTo(null))->will($this->returnValue([['cust_group' => 3, 'website_price' => 80]]));
     $this->assertEquals(20, $this->groupPrice->getValue());
     $this->assertEquals(20, $this->groupPrice->getValue());
 }
예제 #3
0
 /**
  * test for method getValue with type Fixed and selectionPriceType not null
  */
 public function testGetValueTypeFixedWithSelectionPriceType()
 {
     $this->bundleMock->expects($this->once())->method('getPriceType')->will($this->returnValue(\Magento\Bundle\Model\Product\Price::PRICE_TYPE_FIXED));
     $this->bundleMock->expects($this->atLeastOnce())->method('getPriceInfo')->will($this->returnValue($this->priceInfoMock));
     $this->priceInfoMock->expects($this->once())->method('getPrice')->with($this->equalTo(RegularPrice::PRICE_CODE))->will($this->returnValue($this->regularPriceMock));
     $this->regularPriceMock->expects($this->once())->method('getValue')->will($this->returnValue(100));
     $this->bundleMock->expects($this->once())->method('setFinalPrice')->will($this->returnSelf());
     $this->eventManagerMock->expects($this->once())->method('dispatch');
     $this->bundleMock->expects($this->exactly(2))->method('getData')->will($this->returnValueMap([['qty', null, 1], ['final_price', null, 100]]));
     $this->productMock->expects($this->once())->method('getSelectionPriceType')->will($this->returnValue(true));
     $this->productMock->expects($this->any())->method('getSelectionPriceValue')->will($this->returnValue(100));
     $this->discountCalculatorMock->expects($this->once())->method('calculateDiscount')->with($this->equalTo($this->bundleMock), $this->equalTo(100))->will($this->returnValue(70));
     $this->assertEquals(70, $this->selectionPrice->getValue());
 }
 /**
  * test for method getValue with type Fixed and selectionPriceType not null
  *
  * @param bool $useRegularPrice
  * @dataProvider useRegularPriceDataProvider
  */
 public function testGetValueTypeFixedWithSelectionPriceType($useRegularPrice)
 {
     $this->setupSelectionPrice($useRegularPrice);
     $regularPrice = 100.125;
     $discountedPrice = 70.453;
     $actualPrice = $useRegularPrice ? $regularPrice : $discountedPrice;
     $expectedPrice = $useRegularPrice ? round($regularPrice, 2) : round($discountedPrice, 2);
     $this->bundleMock->expects($this->once())->method('getPriceType')->will($this->returnValue(\Magento\Bundle\Model\Product\Price::PRICE_TYPE_FIXED));
     $this->bundleMock->expects($this->atLeastOnce())->method('getPriceInfo')->will($this->returnValue($this->priceInfoMock));
     $this->priceInfoMock->expects($this->once())->method('getPrice')->with($this->equalTo(RegularPrice::PRICE_CODE))->will($this->returnValue($this->regularPriceMock));
     $this->regularPriceMock->expects($this->once())->method('getValue')->will($this->returnValue($actualPrice));
     $this->bundleMock->expects($this->once())->method('setFinalPrice')->will($this->returnSelf());
     $this->eventManagerMock->expects($this->once())->method('dispatch');
     $this->bundleMock->expects($this->exactly(2))->method('getData')->will($this->returnValueMap([['qty', null, 1], ['final_price', null, 100]]));
     $this->productMock->expects($this->once())->method('getSelectionPriceType')->will($this->returnValue(true));
     $this->productMock->expects($this->any())->method('getSelectionPriceValue')->will($this->returnValue($actualPrice));
     if (!$useRegularPrice) {
         $this->discountCalculatorMock->expects($this->once())->method('calculateDiscount')->with($this->equalTo($this->bundleMock), $this->equalTo($actualPrice))->will($this->returnValue($discountedPrice));
     }
     $this->priceCurrencyMock->expects($this->once())->method('round')->with($actualPrice)->will($this->returnValue($expectedPrice));
     $this->assertEquals($expectedPrice, $this->selectionPrice->getValue());
 }