mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-08-01 12:40:11 +02:00
create a Test folder for each pattern
This commit is contained in:
44
Creational/SimpleFactory/Tests/SimpleFactoryTest.php
Normal file
44
Creational/SimpleFactory/Tests/SimpleFactoryTest.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace DesignPatterns\Creational\SimpleFactory\Tests;
|
||||
|
||||
use DesignPatterns\Creational\SimpleFactory\ConcreteFactory;
|
||||
|
||||
/**
|
||||
* SimpleFactoryTest tests the Simple Factory pattern
|
||||
*/
|
||||
class SimpleFactoryTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
||||
protected $factory;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->factory = new ConcreteFactory();
|
||||
}
|
||||
|
||||
public function getType()
|
||||
{
|
||||
return array(
|
||||
array('bicycle'),
|
||||
array('other')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getType
|
||||
*/
|
||||
public function testCreation($type)
|
||||
{
|
||||
$obj = $this->factory->createVehicle($type);
|
||||
$this->assertInstanceOf('DesignPatterns\Creational\SimpleFactory\VehicleInterface', $obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testBadType()
|
||||
{
|
||||
$this->factory->createVehicle('car');
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user