Example #1
0
 /**
  * @dataProvider getValueDataProvider
  */
 public function testGetValue($baseAmount, $optionsValue, $result)
 {
     $this->baseAmount = $baseAmount;
     $this->prepareMock();
     $this->bundleOptionMock->expects($this->once())->method('getValue')->will($this->returnValue($optionsValue));
     $this->assertSame($result, $this->finalPrice->getValue());
 }
Example #2
0
 /**
  * @dataProvider getTestDataForCalculation
  */
 public function testCalculation($optionList, $expected)
 {
     $storeId = 1;
     $this->saleableItemMock->expects($this->any())->method('getStoreId')->will($this->returnValue($storeId));
     $this->selectionFactoryMock->expects($this->any())->method('create')->will($this->returnArgument(1));
     $this->baseCalculator->expects($this->atLeastOnce())->method('getAmount')->will($this->returnValue($this->createAmountMock(['amount' => 0.0])));
     $options = [];
     foreach ($optionList as $optionData) {
         $options[] = $this->createOptionMock($optionData);
     }
     /** @var \PHPUnit_Framework_MockObject_MockObject $optionsCollection */
     $optionsCollection = $this->getMock('Magento\\Bundle\\Model\\Resource\\Option\\Collection', [], [], '', false);
     $optionsCollection->expects($this->atLeastOnce())->method('appendSelections')->will($this->returnSelf());
     $optionsCollection->expects($this->atLeastOnce())->method('getIterator')->will($this->returnValue(new \ArrayIterator($options)));
     /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Catalog\Model\Product\Type\AbstractType $typeMock */
     $typeMock = $this->getMock('Magento\\Bundle\\Model\\Product\\Type', [], [], '', false);
     $typeMock->expects($this->any())->method('setStoreFilter')->with($storeId, $this->saleableItemMock);
     $typeMock->expects($this->any())->method('getOptionsCollection')->with($this->saleableItemMock)->will($this->returnValue($optionsCollection));
     $this->saleableItemMock->expects($this->any())->method('getTypeInstance')->will($this->returnValue($typeMock));
     $this->assertEquals($expected['min'], $this->bundleOptionPrice->getValue());
     $this->assertEquals($expected['max'], $this->bundleOptionPrice->getMaxValue());
 }