Passed
Push — styleci ( 020813...4fa10f )
by Donald
01:42
created

GetInstanceTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testSubsequentCallsToGetInstanceReturnSameInstance() 0 6 1
A testGetInstanceReturnsInstanceOfSingleton() 0 5 1
1
<?php namespace Chekote\NounStore\Singleton;
2
3
use Chekote\NounStore\Singleton;
4
use 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()
17
    {
18
        $instance = SingletonClass::getInstance();
19
20
        $this->assertInstanceOf(SingletonClass::class, $instance);
21
    }
22
23
    public function testSubsequentCallsToGetInstanceReturnSameInstance()
24
    {
25
        $instance1 = SingletonClass::getInstance();
26
        $instance2 = SingletonClass::getInstance();
27
28
        $this->assertEquals(spl_object_hash($instance1), spl_object_hash($instance2));
29
    }
30
}
31