1
0
mirror of https://github.com/DesignPatternsPHP/DesignPatternsPHP.git synced 2025-05-19 21:10:45 +02:00
Dominik Liebler 8b82ed198d cs
2013-09-13 14:19:55 +02:00

45 lines
1.1 KiB
PHP

<?php
namespace DesignPatterns\Tests\TemplateMethod;
use DesignPatterns\TemplateMethod;
/**
* JourneyTest tests all journeys
*/
class JourneyTest extends \PHPUnit_Framework_TestCase
{
public function testBeach()
{
$journey = new TemplateMethod\BeachJourney();
$this->expectOutputRegex('#sun-bathing#');
$journey->takeATrip();
}
public function testCity()
{
$journey = new TemplateMethod\CityJourney();
$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";
}
}