Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
RetryButtonTest.php
Go to the documentation of this file.
1 <?php
7 
8 class RetryButtonTest extends \PHPUnit\Framework\TestCase
9 {
13  protected $block;
14 
18  protected $detailsMock;
19 
23  protected $requestMock;
24 
25  protected function setUp()
26  {
27  $this->detailsMock = $this->getMockBuilder(\Magento\AsynchronousOperations\Model\Operation\Details::class)
28  ->disableOriginalConstructor()
29  ->getMock();
30  $this->requestMock = $this->getMockBuilder(\Magento\Framework\App\RequestInterface::class)
31  ->getMock();
32  $this->block = new \Magento\AsynchronousOperations\Block\Adminhtml\Bulk\Details\RetryButton(
33  $this->detailsMock,
34  $this->requestMock
35  );
36  }
37 
43  public function testGetButtonData($failedCount, $expectedResult)
44  {
45  $details = ['failed_retriable' => $failedCount];
46  $uuid = 'some standard uuid string';
47  $this->requestMock->expects($this->once())
48  ->method('getParam')
49  ->with('uuid')
50  ->willReturn($uuid);
51  $this->detailsMock->expects($this->once())
52  ->method('getDetails')
53  ->with($uuid)
54  ->willReturn($details);
55 
56  $this->assertEquals($expectedResult, $this->block->getButtonData());
57  }
58 
62  public function getButtonDataProvider()
63  {
64  return [
65  [0, []],
66  [
67  20,
68  [
69  'label' => __('Retry'),
70  'class' => 'retry primary',
71  'data_attribute' => [
72  'mage-init' => ['button' => ['event' => 'save']],
73  'form-role' => 'save',
74  ],
75  ]
76  ],
77  ];
78  }
79 }
$details
Definition: vault.phtml:10
__()
Definition: __.php:13