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'); $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"); } }