Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ConnectorTest.php
Go to the documentation of this file.
1 <?php
7 
11 
12 class ConnectorTest extends \PHPUnit\Framework\TestCase
13 {
17  private $objectManagerMock;
18 
22  private $connector;
23 
27  private $signUpCommandMock;
28 
32  private $commands;
33 
34  protected function setUp()
35  {
36  $this->objectManagerMock = $this->getMockBuilder(ObjectManagerInterface::class)
37  ->disableOriginalConstructor()
38  ->getMock();
39  $this->signUpCommandMock = $this->getMockBuilder(SignUpCommand::class)
40  ->disableOriginalConstructor()
41  ->getMock();
42  $this->commands = ['signUp' => SignUpCommand::class];
43  $this->connector = new Connector($this->commands, $this->objectManagerMock);
44  }
45 
46  public function testExecute()
47  {
48  $commandName = 'signUp';
49  $this->objectManagerMock->expects($this->once())
50  ->method('create')
51  ->with($this->commands[$commandName])
52  ->willReturn($this->signUpCommandMock);
53  $this->signUpCommandMock->expects($this->once())
54  ->method('execute')
55  ->willReturn(true);
56  $this->assertTrue($this->connector->execute($commandName));
57  }
58 
62  public function testExecuteCommandNotFound()
63  {
64  $commandName = 'register';
65  $this->connector->execute($commandName);
66  }
67 }