コード例 #1
0
 public function testItRemainsAtFinalDestination()
 {
     $delivery = new Example\Delivery(new Example\AtDestination());
     $delivery->goNext();
     $this->assertEquals('Final Destination', $delivery->getCurrentLocation());
 }
コード例 #2
0
<?php

require 'delivery.php';
use DesignPatterns\State\Example\Delivery as Example;
$delivery = new Example\Delivery(new Example\Processing());
// Warehouse
echo 'The package is in ' . $delivery->getCurrentLocation() . " right now\n";
$delivery->goNext();
// On the way
echo 'The package is in ' . $delivery->getCurrentLocation() . " right now\n";
$delivery->goNext();
// Final Destination
echo 'The package is in ' . $delivery->getCurrentLocation() . " right now\n";