it was created the Creational namespace and append its patterns

This commit is contained in:
Antonio Spinelli
2014-04-15 22:59:59 -03:00
parent 646e0e2fd9
commit 7bf6593e3f
53 changed files with 77 additions and 95 deletions

View File

@@ -0,0 +1,29 @@
<?php
namespace DesignPatterns\Creational\Singleton;
use DesignPatterns\Creational\Singleton\Singleton;
/**
* SingletonTest tests the singleton pattern
*/
class SingletonTest extends \PHPUnit_Framework_TestCase
{
public function testUniqueness()
{
$firstCall = Singleton::getInstance();
$this->assertInstanceOf('DesignPatterns\Creational\Singleton\Singleton', $firstCall);
$secondCall = Singleton::getInstance();
$this->assertSame($firstCall, $secondCall);
}
public function testNoConstructor()
{
$obj = Singleton::getInstance();
$refl = new \ReflectionObject($obj);
$meth = $refl->getMethod('__construct');
$this->assertTrue($meth->isPrivate());
}
}