mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-02-23 17:22:41 +01:00
30 lines
753 B
PHP
30 lines
753 B
PHP
<?php
|
|
|
|
namespace DesignPatterns\Creational\Singleton\Tests;
|
|
|
|
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());
|
|
}
|
|
}
|