adding tests for the command pattern

This commit is contained in:
Trismegiste 2013-05-11 17:34:06 +02:00
parent 6f6e86ee48
commit d520e37d95

View File

@ -0,0 +1,36 @@
<?php
/*
* DesignPatternPHP
*/
namespace DesignPatterns\Tests\Command;
use DesignPatterns\Command\Invoker;
use DesignPatterns\Command\Receiver;
use DesignPatterns\Command\HelloCommand;
/**
* CommandTest has the role of the Client in the Command Pattern
*/
class CommandTest extends \PHPUnit_Framework_TestCase
{
protected $invoker;
protected $receiver;
protected function setUp()
{
// this is the context of the application
$this->invoker = new Invoker();
$this->receiver = new Receiver();
}
public function testInvocation()
{
$this->invoker->setCommand(new HelloCommand($this->receiver));
$this->expectOutputString('Hello World');
$this->invoker->run();
}
}