diff --git a/Tests/TemplateMethod/JourneyTest.php b/Tests/TemplateMethod/JourneyTest.php new file mode 100644 index 0000000..fcfc4e6 --- /dev/null +++ b/Tests/TemplateMethod/JourneyTest.php @@ -0,0 +1,49 @@ +expectOutputRegex('#sun-bathing#'); + $journey->takeATrip(); + } + + public function testCity() + { + $journey = new TemplateMethod\CityJouney(); + $this->expectOutputRegex('#drink#'); + $journey->takeATrip(); + } + + /** + * How to test an abstract template method with PHPUnit + */ + public function testLasVegas() + { + $journey = $this->getMockForAbstractClass('DesignPatterns\TemplateMethod\Journey'); + $journey->expects($this->once()) + ->method('enjoyVacation') + ->will($this->returnCallback(array($this, 'mockUpVacation'))); + $this->expectOutputRegex('#Las Vegas#'); + $journey->takeATrip(); + } + + public function mockUpVacation() + { + echo "Fear and loathing in Las Vegas\n"; + } + +} \ No newline at end of file