mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-07-29 11:10:19 +02:00
unit test
This commit is contained in:
34
Tests/Singleton/SingletonTest.php
Normal file
34
Tests/Singleton/SingletonTest.php
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* DesignPatternPHP
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace DesignPatterns\Tests\Singleton;
|
||||||
|
|
||||||
|
use DesignPatterns\Singleton\Singleton;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SingletonTest tests the singleton pattern
|
||||||
|
*/
|
||||||
|
class SingletonTest extends \PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
|
||||||
|
public function testUniqueness()
|
||||||
|
{
|
||||||
|
$firstCall = Singleton::getInstance();
|
||||||
|
$this->assertInstanceOf('DesignPatterns\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());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Reference in New Issue
Block a user