use constant instead of string

This commit is contained in:
Trismegiste
2013-05-10 21:29:43 +02:00
parent cc765bde41
commit d4ae3bcd8f
5 changed files with 44 additions and 15 deletions

View File

@@ -6,7 +6,9 @@
namespace DesignPatterns\Tests\FactoryMethod;
use DesignPatterns\FactoryMethod;
use DesignPatterns\FactoryMethod\FactoryMethod;
use DesignPatterns\FactoryMethod\GermanFactory;
use DesignPatterns\FactoryMethod\ItalianFactory;
/**
* FactoryMethodTest tests the factory method pattern
@@ -14,20 +16,23 @@ use DesignPatterns\FactoryMethod;
class FactoryMethodTest extends \PHPUnit_Framework_TestCase
{
protected $type = array('cheap', 'fast');
protected $type = array(
FactoryMethod::CHEAP,
FactoryMethod::FAST
);
public function getShop()
{
return array(
array(new FactoryMethod\GermanFactory()),
array(new FactoryMethod\ItalianFactory())
array(new GermanFactory()),
array(new ItalianFactory())
);
}
/**
* @dataProvider getShop
*/
public function testCreation(FactoryMethod\FactoryMethod $shop)
public function testCreation(FactoryMethod $shop)
{
// this test method acts as a client for the factory. We don't care
// about the factory, all we know is it can produce vehicle
@@ -42,7 +47,7 @@ class FactoryMethodTest extends \PHPUnit_Framework_TestCase
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage spaceship is not a valid vehicle
*/
public function testUnknownType(FactoryMethod\FactoryMethod $shop)
public function testUnknownType(FactoryMethod $shop)
{
$shop->create('spaceship');
}