Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
BundleSelectionFactoryTest.php
Go to the documentation of this file.
1 <?php
8 
9 use \Magento\Bundle\Pricing\Price\BundleSelectionFactory;
10 
12 
13 class BundleSelectionFactoryTest extends \PHPUnit\Framework\TestCase
14 {
17 
20 
22  protected $objectManagerMock;
23 
25  protected $bundleMock;
26 
28  protected $selectionMock;
29 
30  protected function setUp()
31  {
32  $this->bundleMock = $this->createMock(\Magento\Catalog\Model\Product::class);
33  $this->selectionMock = $this->createMock(\Magento\Catalog\Model\Product::class);
34 
35  $this->objectManagerMock = $this->createMock(\Magento\Framework\ObjectManagerInterface::class);
36 
37  $this->objectManagerHelper = new ObjectManagerHelper($this);
38  $this->bundleSelectionFactory = $this->objectManagerHelper->getObject(
39  \Magento\Bundle\Pricing\Price\BundleSelectionFactory::class,
40  [
41  'objectManager' => $this->objectManagerMock
42  ]
43  );
44  }
45 
46  public function testCreate()
47  {
48  $result = $this->createMock(\Magento\Bundle\Pricing\Price\BundleSelectionPrice::class);
49  $this->objectManagerMock->expects($this->once())
50  ->method('create')
51  ->with(
53  $this->equalTo(
54  [
55  'test' => 'some value',
56  'bundleProduct' => $this->bundleMock,
57  'saleableItem' => $this->selectionMock,
58  'quantity' => 2.,
59  ]
60  )
61  )
62  ->will($this->returnValue($result));
63  $this->assertSame(
64  $result,
65  $this->bundleSelectionFactory
66  ->create($this->bundleMock, $this->selectionMock, 2., ['test' => 'some value'])
67  );
68  }
69 }