mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-08-06 23:16:33 +02:00
PHP7 Static Factory
This commit is contained in:
@@ -4,33 +4,29 @@ namespace DesignPatterns\Creational\StaticFactory\Tests;
|
||||
|
||||
use DesignPatterns\Creational\StaticFactory\StaticFactory;
|
||||
|
||||
/**
|
||||
* Tests for Static Factory pattern.
|
||||
*/
|
||||
class StaticFactoryTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function getTypeList()
|
||||
public function testCanCreateNumberFormatter()
|
||||
{
|
||||
return array(
|
||||
array('string'),
|
||||
array('number'),
|
||||
$this->assertInstanceOf(
|
||||
'DesignPatterns\Creational\StaticFactory\FormatNumber',
|
||||
StaticFactory::factory('number')
|
||||
);
|
||||
}
|
||||
|
||||
public function testCanCreateStringFormatter()
|
||||
{
|
||||
$this->assertInstanceOf(
|
||||
'DesignPatterns\Creational\StaticFactory\FormatString',
|
||||
StaticFactory::factory('string')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getTypeList
|
||||
*/
|
||||
public function testCreation($type)
|
||||
{
|
||||
$obj = StaticFactory::factory($type);
|
||||
$this->assertInstanceOf('DesignPatterns\Creational\StaticFactory\FormatterInterface', $obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException InvalidArgumentException
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testException()
|
||||
{
|
||||
StaticFactory::factory('');
|
||||
StaticFactory::factory('object');
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user