Bootstrap.php 0000664 00000000310 15152066174 0007235 0 ustar 00 <?php
set_include_path(
dirname(__FILE__) . '/../../library'
. PATH_SEPARATOR . get_include_path()
);
require_once 'Mockery/Loader.php';
$loader = new \Mockery\Loader;
$loader->register();
phpunit.xml 0000664 00000000501 15152066174 0006762 0 ustar 00 <phpunit bootstrap="./Bootstrap.php">
<testsuite name="Starship Test Suite">
<directory>./</directory>
</testsuite>
<listeners>
<listener class="\Mockery\Adapter\Phpunit\TestListener"
file="Mockery/Adapter/Phpunit/TestListener.php">
</listener>
</listeners>
</phpunit>
StarshipTest.php 0000664 00000001317 15152066174 0007725 0 ustar 00 <?php
use \Mockery as M;
require_once 'Starship.php';
class StarshipTest extends PHPUnit_Framework_TestCase
{
public function testEngineeringResponseToEnteringOrbit()
{
$mock = M::mock('Engineering');
$mock->shouldReceive('disengageWarp')->once()->ordered();
$mock->shouldReceive('divertPower')->with(0.40, 'sensors')->once()->ordered();
$mock->shouldReceive('divertPower')->with(0.30, 'auxengines')->once()->ordered();
$mock->shouldReceive('runDiagnosticLevel')->with(1)->once()->ordered();
$mock->shouldReceive('runDiagnosticLevel')->with(M::type('int'))->zeroOrMoreTimes();
$starship = new Starship($mock);
$starship->enterOrbit();
}
}
Starship.php 0000664 00000001147 15152066174 0007066 0 ustar 00 <?php
class Starship
{
protected $_engineering = null;
public function __construct($engineering)
{
$this->_engineering = $engineering;
}
public function enterOrbit()
{
$this->_engineering->disengageWarp();
$this->_engineering->runDiagnosticLevel(5);
$this->_engineering->divertPower(0.40, 'sensors');
$this->_engineering->divertPower(0.30, 'auxengines');
$this->_engineering->runDiagnosticLevel(1);
// We can add more runDiagnosticLevel() calls without failing the test
// anywhere above since they are unordered.
}
}