Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ItemIdProcessorTest.php
Go to the documentation of this file.
1 <?php
7 
10 
11 class ItemIdProcessorTest extends \PHPUnit\Framework\TestCase
12 {
14  protected $model;
15 
16  protected function setUp()
17  {
18  $this->model = new ItemIdProcessor();
19  }
20 
27  public function testProcess($itemId, array $jsLayout, array $result)
28  {
32  $itemMock = $this->getMockBuilder(\Magento\Quote\Model\Quote\Item::class)
33  ->disableOriginalConstructor()
34  ->getMock();
35  $itemMock->expects($this->any())
36  ->method('getId')
37  ->willReturn($itemId);
38 
39  $this->assertEquals($result, $this->model->process($jsLayout, $itemMock));
40  }
41 
45  public function dataProviderProcess()
46  {
47  return [
48  [
49  12,
50  ['components' => []],
51  ['components' => []],
52  ],
53  [
54  21,
55  ['components' => ['giftOptionsCartItem' => []]],
56  ['components' => ['giftOptionsCartItem-21' => ['config' => ['itemId' => 21]]]],
57  ],
58  [
59  23,
60  ['components' => ['giftOptionsCartItem' => ['config' => ['key' => 'value']]]],
61  ['components' => ['giftOptionsCartItem-23' => ['config' => ['key' => 'value', 'itemId' => 23]]]],
62  ],
63  [
64  23,
65  ['components' => ['giftOptionsCartItem' => ['config' => ['key' => 'value'], 'key2' => 'value2']]],
66  [
67  'components' => [
68  'giftOptionsCartItem-23' => [
69  'config' => ['key' => 'value', 'itemId' => 23], 'key2' => 'value2'
70  ]
71  ]
72  ],
73  ],
74  ];
75  }
76 }