Files
DesignPatternsPHP/Creational/SimpleFactory/Tests/SimpleFactoryTest.php
2016-01-16 17:20:13 +03:00

44 lines
911 B
PHP

<?php
namespace DesignPatterns\Creational\SimpleFactory\Tests;
use DesignPatterns\Creational\SimpleFactory\SimpleFactory;
/**
* SimpleFactoryTest tests the Simple Factory pattern.
*/
class SimpleFactoryTest extends \PHPUnit_Framework_TestCase
{
protected $factory;
protected function setUp()
{
$this->factory = new SimpleFactory();
}
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');
}
}