Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
All Data Structures Namespaces Files Functions Variables Pages
BundleOptionRegularPriceTest.php
Go to the documentation of this file.
1 <?php
6 declare(strict_types=1);
7 
9 
18 
22 class BundleOptionRegularPriceTest extends \PHPUnit\Framework\TestCase
23 {
27  private $bundleOptionRegularPrice;
28 
32  private $objectManagerHelper;
33 
37  private $saleableItemMock;
38 
42  private $bundleCalculatorMock;
43 
47  private $bundleOptionsMock;
48 
52  protected function setUp()
53  {
54  $this->bundleOptionsMock = $this->createMock(BundleOptions::class);
55  $this->saleableItemMock = $this->createMock(Product::class);
56  $this->bundleCalculatorMock = $this->createMock(Calculator::class);
57 
58  $this->objectManagerHelper = new ObjectManagerHelper($this);
59  $this->bundleOptionRegularPrice = $this->objectManagerHelper->getObject(
60  BundleOptionRegularPrice::class,
61  [
62  'saleableItem' => $this->saleableItemMock,
63  'quantity' => 1.,
64  'calculator' => $this->bundleCalculatorMock,
65  'bundleOptions' => $this->bundleOptionsMock,
66  ]
67  );
68  }
69 
75  public function testGetOptions()
76  {
77  $collection = $this->createMock(Collection::class);
78  $this->bundleOptionsMock->expects($this->any())
79  ->method('getOptions')
80  ->will($this->returnValue($collection));
81  $this->assertEquals($collection, $this->bundleOptionRegularPrice->getOptions());
82  }
83 
89  public function testGetOptionSelectionAmount()
90  {
91  $selectionAmount = $this->createMock(AmountInterface::class);
92  $product = $this->createMock(Product::class);
93  $selection = $this->createMock(Selection::class);
94  $this->bundleOptionsMock->expects($this->any())
95  ->method('getOptionSelectionAmount')
96  ->will($this->returnValue($selectionAmount))
97  ->with($product, $selection, true);
98  $this->assertEquals($selectionAmount, $this->bundleOptionRegularPrice->getOptionSelectionAmount($selection));
99  }
100 
106  public function testGetAmount()
107  {
108  $amountMock = $this->createMock(AmountInterface::class);
109  $this->bundleCalculatorMock->expects($this->once())
110  ->method('getOptionsAmount')
111  ->with($this->equalTo($this->saleableItemMock))
112  ->will($this->returnValue($amountMock));
113  $this->assertSame($amountMock, $this->bundleOptionRegularPrice->getAmount());
114  }
115 
121  public function testGetValue()
122  {
123  $value = 1;
124  $this->bundleOptionsMock->expects($this->any())->method('calculateOptions')->will($this->returnValue($value));
125  $this->assertEquals($value, $this->bundleOptionRegularPrice->getValue());
126  }
127 }
$value
Definition: gender.phtml:16