GetInstanceTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 15
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testGetInstanceReturnsInstanceOfSingleton() 0 5 1
A testSubsequentCallsToGetInstanceReturnSameInstance() 0 6 1
1
<?php namespace Unit\Chekote\NounStore\Singleton;
2
3
use Chekote\NounStore\Singleton;
4
use Unit\Chekote\NounStore\TestCase;
5
6
class SingletonClass
7
{
8
    use Singleton;
9
}
10
11
/**
12
 * @covers \Chekote\NounStore\Singleton::getInstance()
13
 */
14
class GetInstanceTest extends TestCase
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
15
{
16
    public function testGetInstanceReturnsInstanceOfSingleton(): void
17
    {
18
        $instance = SingletonClass::getInstance();
19
20
        $this->assertInstanceOf(SingletonClass::class, $instance);
21
    }
22
23
    public function testSubsequentCallsToGetInstanceReturnSameInstance(): void
24
    {
25
        $instance1 = SingletonClass::getInstance();
26
        $instance2 = SingletonClass::getInstance();
27
28
        $this->assertEquals(spl_object_hash($instance1), spl_object_hash($instance2));
29
    }
30
}
31