DataTest.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Bundle\Test\Unit\Helper;
  7. use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
  8. class DataTest extends \PHPUnit\Framework\TestCase
  9. {
  10. /**
  11. * @var \Magento\Catalog\Model\ProductTypes\ConfigInterface|\PHPUnit_Framework_MockObject_MockObject
  12. */
  13. protected $config;
  14. /**
  15. * @var \Magento\Bundle\Helper\Data
  16. */
  17. protected $helper;
  18. protected function setUp()
  19. {
  20. $this->config = $this->createMock(\Magento\Catalog\Model\ProductTypes\ConfigInterface::class);
  21. $this->helper = (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this))->getObject(
  22. \Magento\Bundle\Helper\Data::class,
  23. ['config' => $this->config]
  24. );
  25. }
  26. public function testGetAllowedSelectionTypes()
  27. {
  28. $configData = ['allowed_selection_types' => ['foo', 'bar', 'baz']];
  29. $this->config->expects($this->once())->method('getType')->with('bundle')->will($this->returnValue($configData));
  30. $this->assertEquals($configData['allowed_selection_types'], $this->helper->getAllowedSelectionTypes());
  31. }
  32. public function testGetAllowedSelectionTypesIfTypesIsNotSet()
  33. {
  34. $configData = [];
  35. $this->config->expects($this->once())->method('getType')
  36. ->with(\Magento\Catalog\Model\Product\Type::TYPE_BUNDLE)
  37. ->will($this->returnValue($configData));
  38. $this->assertEquals([], $this->helper->getAllowedSelectionTypes());
  39. }
  40. }