Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
DoneButtonTest.php
Go to the documentation of this file.
1 <?php
7 
9 
10 class DoneButtonTest extends \PHPUnit\Framework\TestCase
11 {
15  protected $block;
16 
20  protected $bulkStatusMock;
21 
25  protected $requestMock;
26 
27  protected function setUp()
28  {
29  $this->bulkStatusMock = $this->createMock(\Magento\Framework\Bulk\BulkStatusInterface::class);
30  $this->requestMock = $this->getMockBuilder(\Magento\Framework\App\RequestInterface::class)
31  ->getMock();
32  $this->block = new \Magento\AsynchronousOperations\Block\Adminhtml\Bulk\Details\DoneButton(
33  $this->bulkStatusMock,
34  $this->requestMock
35  );
36  }
37 
44  public function testGetButtonData($failedCount, $buttonsParam, $expectedResult)
45  {
46  $uuid = 'some standard uuid string';
47  $this->requestMock->expects($this->exactly(2))
48  ->method('getParam')
49  ->withConsecutive(['uuid'], ['buttons'])
50  ->willReturnOnConsecutiveCalls($uuid, $buttonsParam);
51  $this->bulkStatusMock->expects($this->once())
52  ->method('getOperationsCountByBulkIdAndStatus')
54  ->willReturn($failedCount);
55 
56  $this->assertEquals($expectedResult, $this->block->getButtonData());
57  }
58 
62  public function getButtonDataProvider()
63  {
64  return [
65  [1, 0, []],
66  [0, 0, []],
67  [
68  0,
69  1,
70  [
71  'label' => __('Done'),
72  'class' => 'primary',
73  'sort_order' => 10,
74  'on_click' => '',
75  'data_attribute' => [
76  'mage-init' => [
77  'Magento_Ui/js/form/button-adapter' => [
78  'actions' => [
79  [
80  'targetName' => 'notification_area.notification_area.modalContainer.modal',
81  'actionName' => 'closeModal'
82  ],
83  ],
84  ],
85  ],
86  ],
87  ]
88  ],
89  ];
90  }
91 }
__()
Definition: __.php:13