Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
DirectorTest.php
Go to the documentation of this file.
1 <?php
11 
12 class DirectorTest extends \PHPUnit\Framework\TestCase
13 {
17  protected $_model;
18 
23 
27  protected $_builderMock;
28 
32  protected $_logger;
33 
37  protected $_commandMock;
38 
39  protected function setUp()
40  {
41  $this->_builderMock = $this->createMock(\Magento\Backend\Model\Menu\Builder::class);
42  $this->_logger = $this->createMock(\Psr\Log\LoggerInterface::class);
43  $this->_commandMock = $this->createPartialMock(
44  \Magento\Backend\Model\Menu\Builder\AbstractCommand::class,
45  ['getId', '_execute', 'execute', 'chain']
46  );
47  $this->_commandFactoryMock = $this->createPartialMock(
48  \Magento\Backend\Model\Menu\Builder\CommandFactory::class,
49  ['create']
50  );
51  $this->_commandFactoryMock->expects(
52  $this->any()
53  )->method(
54  'create'
55  )->will(
56  $this->returnValue($this->_commandMock)
57  );
58 
59  $this->_commandMock->expects($this->any())->method('getId')->will($this->returnValue(true));
60  $this->_model = new \Magento\Backend\Model\Menu\Director\Director($this->_commandFactoryMock);
61  }
62 
63  public function testDirectWithExistKey()
64  {
65  $config = [['type' => 'update'], ['type' => 'remove'], ['type' => 'added']];
66  $this->_builderMock->expects($this->at(2))->method('processCommand')->with($this->_commandMock);
67  $this->_logger->expects($this->at(1))->method('debug');
68  $this->_commandMock->expects($this->at(1))->method('getId');
69  $this->_model->direct($config, $this->_builderMock, $this->_logger);
70  }
71 }
$config
Definition: fraud_order.php:17