mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-02-24 09:42:24 +01:00
adding tests for the command pattern
This commit is contained in:
parent
6f6e86ee48
commit
d520e37d95
36
Tests/Command/CommandTest.php
Normal file
36
Tests/Command/CommandTest.php
Normal 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();
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user