public function testInvocation()
 {
     $invoker = new Invoker();
     $receiver = new Receiver();
     $invoker->setCommand(new HelloCommand($receiver));
     $invoker->run();
     $this->assertEquals($receiver->getOutput(), 'Hello World');
 }
 public function testInvocation()
 {
     $this->invoker->setCommand(new HelloCommand($this->receiver));
     $this->invoker->run();
     $this->assertEquals($this->receiver->getOutput(), 'Hello World');
     $messageDateCommand = new AddMessageDateCommand($this->receiver);
     $messageDateCommand->execute();
     $this->invoker->run();
     $this->assertEquals($this->receiver->getOutput(), "Hello World\nHello World [" . date('Y-m-d') . ']');
     $messageDateCommand->undo();
     $this->invoker->run();
     $this->assertEquals($this->receiver->getOutput(), "Hello World\nHello World [" . date('Y-m-d') . "]\nHello World");
 }
Example #3
0
 public function testInvocation()
 {
     $this->invoker->setCommand(new HelloCommand($this->receiver));
     $this->expectOutputString('Hello World');
     $this->invoker->run();
 }