Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
NotificationActionsTest.php
Go to the documentation of this file.
1 <?php
8 
11 
12 class NotificationActionsTest extends \PHPUnit\Framework\TestCase
13 {
17  private $context;
18 
22  private $uiComponentFactory;
23 
27  private $actionColumn;
28 
32  protected function setUp()
33  {
34  $this->context = $this->createMock(\Magento\Framework\View\Element\UiComponent\ContextInterface::class);
35  $this->uiComponentFactory = $this->createMock(\Magento\Framework\View\Element\UiComponentFactory::class);
36  $processor = $this->createPartialMock(
37  \Magento\Framework\View\Element\UiComponent\Processor::class,
38  ['getProcessor']
39  );
40  $this->context->expects($this->never())->method('getProcessor')->will($this->returnValue($processor));
41  $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
42  $this->actionColumn = $objectManager->getObject(
43  \Magento\AsynchronousOperations\Ui\Component\Listing\Column\NotificationActions::class,
44  [
45  'context' => $this->context,
46  'uiComponentFactory' => $this->uiComponentFactory,
47  'components' => [],
48  'data' => ['name' => 'actions']
49  ]
50  );
51  }
52 
53  public function testPrepareDataSource()
54  {
55  $testData['data']['items'] = [
56  [
57  'key' => 'value',
58  ],
59  [
60  BulkSummary::BULK_ID => 'uuid-1',
62  ],
63  [
64  BulkSummary::BULK_ID => 'uuid-2',
65  ],
66  ];
67  $expectedResult['data']['items'] = [
68  [
69  'key' => 'value',
70  ],
71  [
72  BulkSummary::BULK_ID => 'uuid-1',
74  'actions' => [
75  'details' => [
76  'href' => '#',
77  'label' => __('View Details'),
78  'callback' => [
79  [
80  'provider' => 'notification_area.notification_area.modalContainer.modal.insertBulk',
81  'target' => 'destroyInserted',
82  ],
83  [
84  'provider' => 'notification_area.notification_area.modalContainer.modal.insertBulk',
85  'target' => 'updateData',
86  'params' => [
87  BulkSummary::BULK_ID => 'uuid-1',
88  ],
89  ],
90  [
91  'provider' => 'notification_area.notification_area.modalContainer.modal',
92  'target' => 'openModal',
93  ],
94  [
95  'provider' => 'ns = notification_area, index = columns',
96  'target' => 'dismiss',
97  'params' => ['uuid-1'],
98  ],
99  ],
100  ],
101  ],
102  ],
103  [
104  BulkSummary::BULK_ID => 'uuid-2',
105  'actions' => [
106  'details' => [
107  'href' => '#',
108  'label' => __('View Details'),
109  'callback' => [
110  [
111  'provider' => 'notification_area.notification_area.modalContainer.modal.insertBulk',
112  'target' => 'destroyInserted',
113  ],
114  [
115  'provider' => 'notification_area.notification_area.modalContainer.modal.insertBulk',
116  'target' => 'updateData',
117  'params' => [
118  BulkSummary::BULK_ID => 'uuid-2',
119  ],
120  ],
121  [
122  'provider' => 'notification_area.notification_area.modalContainer.modal',
123  'target' => 'openModal',
124  ],
125  ],
126  ],
127  ],
128  ],
129  ];
130  $this->assertEquals($expectedResult, $this->actionColumn->prepareDataSource($testData));
131  }
132 }
$objectManager
Definition: bootstrap.php:17
$processor
Definition: 404.php:10
__()
Definition: __.php:13