BundleSelectionFactoryTest.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Bundle\Test\Unit\Pricing\Price;
  7. use \Magento\Bundle\Pricing\Price\BundleSelectionFactory;
  8. use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
  9. class BundleSelectionFactoryTest extends \PHPUnit\Framework\TestCase
  10. {
  11. /** @var \Magento\Bundle\Pricing\Price\BundleSelectionFactory */
  12. protected $bundleSelectionFactory;
  13. /** @var ObjectManagerHelper */
  14. protected $objectManagerHelper;
  15. /** @var \Magento\Framework\ObjectManagerInterface|\PHPUnit_Framework_MockObject_MockObject */
  16. protected $objectManagerMock;
  17. /** @var \Magento\Framework\Pricing\SaleableInterface|\PHPUnit_Framework_MockObject_MockObject */
  18. protected $bundleMock;
  19. /** @var \Magento\Framework\Pricing\SaleableInterface|\PHPUnit_Framework_MockObject_MockObject */
  20. protected $selectionMock;
  21. protected function setUp()
  22. {
  23. $this->bundleMock = $this->createMock(\Magento\Catalog\Model\Product::class);
  24. $this->selectionMock = $this->createMock(\Magento\Catalog\Model\Product::class);
  25. $this->objectManagerMock = $this->createMock(\Magento\Framework\ObjectManagerInterface::class);
  26. $this->objectManagerHelper = new ObjectManagerHelper($this);
  27. $this->bundleSelectionFactory = $this->objectManagerHelper->getObject(
  28. \Magento\Bundle\Pricing\Price\BundleSelectionFactory::class,
  29. [
  30. 'objectManager' => $this->objectManagerMock
  31. ]
  32. );
  33. }
  34. public function testCreate()
  35. {
  36. $result = $this->createMock(\Magento\Bundle\Pricing\Price\BundleSelectionPrice::class);
  37. $this->objectManagerMock->expects($this->once())
  38. ->method('create')
  39. ->with(
  40. $this->equalTo(BundleSelectionFactory::SELECTION_CLASS_DEFAULT),
  41. $this->equalTo(
  42. [
  43. 'test' => 'some value',
  44. 'bundleProduct' => $this->bundleMock,
  45. 'saleableItem' => $this->selectionMock,
  46. 'quantity' => 2.,
  47. ]
  48. )
  49. )
  50. ->will($this->returnValue($result));
  51. $this->assertSame(
  52. $result,
  53. $this->bundleSelectionFactory
  54. ->create($this->bundleMock, $this->selectionMock, 2., ['test' => 'some value'])
  55. );
  56. }
  57. }