Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
DataTest.php
Go to the documentation of this file.
1 <?php
7 
9 
10 class DataTest extends \PHPUnit\Framework\TestCase
11 {
15  protected $config;
16 
20  protected $helper;
21 
22  protected function setUp()
23  {
24  $this->config = $this->createMock(\Magento\Catalog\Model\ProductTypes\ConfigInterface::class);
25  $this->helper = (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this))->getObject(
26  \Magento\Bundle\Helper\Data::class,
27  ['config' => $this->config]
28  );
29  }
30 
31  public function testGetAllowedSelectionTypes()
32  {
33  $configData = ['allowed_selection_types' => ['foo', 'bar', 'baz']];
34  $this->config->expects($this->once())->method('getType')->with('bundle')->will($this->returnValue($configData));
35 
36  $this->assertEquals($configData['allowed_selection_types'], $this->helper->getAllowedSelectionTypes());
37  }
38 
40  {
41  $configData = [];
42  $this->config->expects($this->once())->method('getType')
43  ->with(\Magento\Catalog\Model\Product\Type::TYPE_BUNDLE)
44  ->will($this->returnValue($configData));
45 
46  $this->assertEquals([], $this->helper->getAllowedSelectionTypes());
47  }
48 }