Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AbstractCommandTest.php
Go to the documentation of this file.
1 <?php
7 
8 class AbstractCommandTest extends \PHPUnit\Framework\TestCase
9 {
13  protected $_model;
14 
15  protected function setUp()
16  {
17  $this->_model = $this->getMockForAbstractClass(
18  \Magento\Backend\Model\Menu\Builder\AbstractCommand::class,
19  [['id' => 'item']]
20  );
21  }
22 
27  {
28  $this->getMockForAbstractClass(\Magento\Backend\Model\Menu\Builder\AbstractCommand::class);
29  }
30 
32  {
33  $command1 = $this->getMockBuilder(\Magento\Backend\Model\Menu\Builder\Command\Update::class)
34  ->setConstructorArgs([['id' => 1]])
35  ->getMock();
36  $command2 = $this->getMockBuilder(\Magento\Backend\Model\Menu\Builder\Command\Remove::class)
37  ->setConstructorArgs([['id' => 1]])
38  ->getMock();
39  $command1->expects($this->once())->method('chain')->with($this->equalTo($command2));
40 
41  $this->_model->chain($command1);
42  $this->_model->chain($command2);
43  }
44 
46  {
47  $itemParams = [];
48  $this->_model->expects(
49  $this->once()
50  )->method(
51  '_execute'
52  )->with(
53  $this->equalTo($itemParams)
54  )->will(
55  $this->returnValue($itemParams)
56  );
57 
58  $command1 = $this->getMockBuilder(\Magento\Backend\Model\Menu\Builder\Command\Update::class)
59  ->setConstructorArgs([['id' => 1]])
60  ->getMock();
61 
62  $command1->expects(
63  $this->once()
64  )->method(
65  'execute'
66  )->with(
67  $this->equalTo($itemParams)
68  )->will(
69  $this->returnValue($itemParams)
70  );
71 
72  $this->_model->chain($command1);
73  $this->assertEquals($itemParams, $this->_model->execute($itemParams));
74  }
75 }