Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ChannelDataBuilderTest.php
Go to the documentation of this file.
1 <?php
7 
11 use PHPUnit_Framework_MockObject_MockObject as MockObject;
12 
18 class ChannelDataBuilderTest extends \PHPUnit\Framework\TestCase
19 {
23  private $productMetadata;
24 
28  private $config;
29 
33  private $builder;
34 
38  protected function setUp()
39  {
40  $this->productMetadata = $this->getMockBuilder(ProductMetadataInterface::class)
41  ->disableOriginalConstructor()
42  ->getMock();
43  $this->config = $this->getMockBuilder(Config::class)
44  ->disableOriginalConstructor()
45  ->getMock();
46  $this->builder = new ChannelDataBuilder($this->productMetadata, $this->config);
47  }
48 
55  public function testBuild($edition, array $expected)
56  {
57  $buildSubject = [];
58 
59  $this->config->method('getValue')
60  ->with(self::equalTo('channel'))
61  ->willReturn(null);
62 
63  $this->productMetadata->method('getEdition')
64  ->willReturn($edition);
65 
66  self::assertEquals($expected, $this->builder->build($buildSubject));
67  }
68 
73  {
74  $channel = 'Magento2_Cart_ConfigEdition_BT';
75 
76  $this->config->method('getValue')
77  ->with(self::equalTo('channel'))
78  ->willReturn($channel);
79 
80  $this->productMetadata->expects(self::never())
81  ->method('getEdition');
82 
83  self::assertEquals(
84  [
85  'channel' => $channel
86  ],
87  $this->builder->build([])
88  );
89  }
90 
95  public function buildDataProvider()
96  {
97  return [
98  ['FirstEdition', ['channel' => 'Magento2_Cart_FirstEdition_BT']],
99  ['SecondEdition', ['channel' => 'Magento2_Cart_SecondEdition_BT']],
100  ];
101  }
102 }
foreach(array_keys($composerData['require']) as $requiredPackage) if(empty($edition)) if(!empty($opts['edition'])) $edition