mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-02-24 09:42:24 +01:00
43 lines
1.0 KiB
PHP
43 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace DesignPatterns\Creational\Builder;
|
|
|
|
use DesignPatterns\Creational\Builder\Director;
|
|
use DesignPatterns\Creational\Builder\CarBuilder;
|
|
use DesignPatterns\Creational\Builder\BikeBuilder;
|
|
use DesignPatterns\Creational\Builder\BuilderInterface;
|
|
|
|
/**
|
|
* DirectorTest tests the builder pattern
|
|
*/
|
|
class DirectorTest extends \PHPUnit_Framework_TestCase
|
|
{
|
|
|
|
protected $director;
|
|
|
|
protected function setUp()
|
|
{
|
|
$this->director = new Director();
|
|
}
|
|
|
|
public function getBuilder()
|
|
{
|
|
return array(
|
|
array(new CarBuilder()),
|
|
array(new BikeBuilder())
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Here we test the build process. Notice that the client don't know
|
|
* anything about the contrete builder.
|
|
*
|
|
* @dataProvider getBuilder
|
|
*/
|
|
public function testBuild(BuilderInterface $builder)
|
|
{
|
|
$newVehicle = $this->director->build($builder);
|
|
$this->assertInstanceOf('DesignPatterns\Creational\Builder\Parts\Vehicle', $newVehicle);
|
|
}
|
|
}
|