objectManagerMock = $this->getMockBuilder(ObjectManagerInterface::class) ->disableOriginalConstructor() ->getMock(); $this->signUpCommandMock = $this->getMockBuilder(SignUpCommand::class) ->disableOriginalConstructor() ->getMock(); $this->commands = ['signUp' => SignUpCommand::class]; $this->connector = new Connector($this->commands, $this->objectManagerMock); } public function testExecute() { $commandName = 'signUp'; $this->objectManagerMock->expects($this->once()) ->method('create') ->with($this->commands[$commandName]) ->willReturn($this->signUpCommandMock); $this->signUpCommandMock->expects($this->once()) ->method('execute') ->willReturn(true); $this->assertTrue($this->connector->execute($commandName)); } /** * @expectedException \Magento\Framework\Exception\NotFoundException */ public function testExecuteCommandNotFound() { $commandName = 'register'; $this->connector->execute($commandName); } }