PHP7 Command

This commit is contained in:
Dominik Liebler
2016-09-22 09:25:26 +02:00
parent 1da5772226
commit a6b09d6b18
8 changed files with 40 additions and 77 deletions

View File

@@ -6,31 +6,15 @@ use DesignPatterns\Behavioral\Command\HelloCommand;
use DesignPatterns\Behavioral\Command\Invoker;
use DesignPatterns\Behavioral\Command\Receiver;
/**
* CommandTest has the role of the Client in the Command Pattern.
*/
class CommandTest extends \PHPUnit_Framework_TestCase
{
/**
* @var Invoker
*/
protected $invoker;
/**
* @var Receiver
*/
protected $receiver;
protected function setUp()
{
$this->invoker = new Invoker();
$this->receiver = new Receiver();
}
public function testInvocation()
{
$this->invoker->setCommand(new HelloCommand($this->receiver));
$this->invoker->run();
$this->assertEquals($this->receiver->getOutput(), 'Hello World');
$invoker = new Invoker();
$receiver = new Receiver();
$invoker->setCommand(new HelloCommand($receiver));
$invoker->run();
$this->assertEquals($receiver->getOutput(), 'Hello World');
}
}