mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-08-10 00:46:38 +02:00
PHP7 Singleton und Multiton
This commit is contained in:
27
Creational/Multiton/Tests/MultitonTest.php
Normal file
27
Creational/Multiton/Tests/MultitonTest.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace DesignPatterns\Creational\Singleton\Tests;
|
||||
|
||||
use DesignPatterns\Creational\Multiton\Multiton;
|
||||
|
||||
class MultitonTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testUniqueness()
|
||||
{
|
||||
$firstCall = Multiton::getInstance(Multiton::INSTANCE_1);
|
||||
$secondCall = Multiton::getInstance(Multiton::INSTANCE_1);
|
||||
|
||||
$this->assertInstanceOf('DesignPatterns\Creational\Multiton\Multiton', $firstCall);
|
||||
$this->assertSame($firstCall, $secondCall);
|
||||
}
|
||||
|
||||
public function testUniquenessForEveryInstance()
|
||||
{
|
||||
$firstCall = Multiton::getInstance(Multiton::INSTANCE_1);
|
||||
$secondCall = Multiton::getInstance(Multiton::INSTANCE_2);
|
||||
|
||||
$this->assertInstanceOf('DesignPatterns\Creational\Multiton\Multiton', $firstCall);
|
||||
$this->assertInstanceOf('DesignPatterns\Creational\Multiton\Multiton', $secondCall);
|
||||
$this->assertNotSame($firstCall, $secondCall);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user