Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
VariationMatrixTest.php
Go to the documentation of this file.
1 <?php
8 
10 
11 class VariationMatrixTest extends \PHPUnit\Framework\TestCase
12 {
14  protected $model;
15 
18 
19  protected function setUp()
20  {
21  $this->objectManagerHelper = new ObjectManagerHelper($this);
22 
23  $this->model = $this->objectManagerHelper->getObject(
24  \Magento\ConfigurableProduct\Model\Product\Type\VariationMatrix::class
25  );
26  }
27 
28  public function testGetVariations()
29  {
30  $result = [
31  [
32  130 => [
33  'value' => '3',
34  'label' => 'red',
35  'price' => ['value_index' => '3', 'pricing_value' => '', 'is_percent' => '0', 'include' => '1',],
36  ],
37  ],
38  [
39  130 => [
40  'value' => '4',
41  'label' => 'blue',
42  'price' => ['value_index' => '4', 'pricing_value' => '', 'is_percent' => '0', 'include' => '1',],
43  ],
44  ],
45  ];
46 
47  $input = [
48  130 => [
49  'values' => [
50  [
51  'value_index' => '3',
52  'pricing_value' => '',
53  'is_percent' => '0',
54  'include' => '1'
55  ],
56  [
57  'value_index' => '4',
58  'pricing_value' => '',
59  'is_percent' => '0',
60  'include' => '1'
61  ],
62  ],
63  'attribute_id' => '130',
64  'options' => [['value' => '3', 'label' => 'red',], ['value' => '4', 'label' => 'blue',],],
65  ],
66  ];
67 
68  $this->assertEquals($result, $this->model->getVariations($input));
69  }
70 }