public function testExecute() { $mapper = m::mock('StdClass'); $command = m::mock('StdClass'); $bus = m::mock('StdClass'); $manager = m::mock('JildertMiedema\\Commander\\Manager'); $manager->shouldReceive('getMapper')->andReturn($mapper); $manager->shouldReceive('getCommandBus')->andReturn($bus); $mapper->shouldReceive('mapInputToCommand')->once()->with('TestCommand', ['test' => '123'])->andReturn($command); $bus->shouldReceive('decorate')->once()->with('test'); $bus->shouldReceive('execute')->once()->with($command)->andReturn('Result'); $executor = new Executor($manager); $result = $executor->execute('TestCommand', ['test' => 123], ['test']); $this->assertEquals('Result', $result); }
<?php require_once '../vendor/autoload.php'; require_once 'general/TestCommand.php'; require_once 'general/TestCommandHandler.php'; require_once 'general/TestCommandValidator.php'; require_once 'general/TestSanitizer.php'; use JildertMiedema\Commander\Manager; use JildertMiedema\Commander\Vanilla\Executor; $manager = new Manager(); $executor = new Executor($manager); echo $executor->execute('TestCommand', null, ['TestSanitizer']);