Skip to content

Commit 1b9f617

Browse files
committed
[TEST] Add UnitTest for Singleton trait
1 parent d70ce4a commit 1b9f617

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

tests/Unit/SingletonTest.php

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
namespace AppZap\PHPFramework\Tests\Unit;
3+
4+
use AppZap\PHPFramework\Domain\Repository\AbstractDomainRepository;
5+
6+
class TestRepository1 extends AbstractDomainRepository{}
7+
class TestRepository2 extends AbstractDomainRepository{}
8+
9+
class SingletonTest extends \PHPUnit_Framework_TestCase {
10+
11+
/**
12+
* @test
13+
*/
14+
public function getTheSameInstanceEveryTime() {
15+
$repo1Instance1 = TestRepository1::getInstance();
16+
$repo1Instance2 = TestRepository1::getInstance();
17+
$this->assertSame($repo1Instance1, $repo1Instance2);
18+
}
19+
20+
/**
21+
* @test
22+
*/
23+
public function getRightClass() {
24+
$repo1Instance1 = TestRepository1::getInstance();
25+
$repo2Instance1 = TestRepository2::getInstance();
26+
$this->assertTrue($repo1Instance1 instanceof TestRepository1);
27+
$this->assertTrue($repo2Instance1 instanceof TestRepository2);
28+
}
29+
30+
}

0 commit comments

Comments
 (0)