Completed
Push — master ( b18e4f...bdcd4e )
by Korotkov
02:54
created

PrototypeTest::testCountInstances()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
eloc 5
c 2
b 0
f 0
nc 1
nop 0
dl 0
loc 7
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * @author    : Korotkov Danila <[email protected]>
7
 * @license   https://mit-license.org/ MIT
8
 */
9
10
use Creational\Prototype\Prototype;
11
use Creational\Prototype\AbstractPrototype;
12
use PHPUnit\Framework\TestCase as PHPUnit_Framework_TestCase;
13
14
/**
15
 * Class PrototypeTest
16
 */
17
class PrototypeTest extends PHPUnit_Framework_TestCase
18
{
19
    /**
20
     * @var AbstractPrototype
21
     */
22
    private $prototype;
23
24
    protected function setUp(): void
25
    {
26
        $this->prototype = new Prototype();
27
    }
28
29
    public function testInstances()
30
    {
31
        $clonedFirstPrototype = $this->getPrototype()->getPrototype();
32
        $this->assertFalse($clonedFirstPrototype === $this->getPrototype());
33
        $this->assertInstanceOf(Prototype::class, $clonedFirstPrototype);
34
    }
35
36
    public function testCountInstances()
37
    {
38
        $this->assertEquals(AbstractPrototype::$count, 1);
39
        $this->getPrototype()->getPrototype();
40
        $this->assertEquals(AbstractPrototype::$count, 2);
41
        $this->getPrototype()->getPrototype();
42
        $this->assertEquals(AbstractPrototype::$count, 3);
43
    }
44
45
    /**
46
     * @return AbstractPrototype
47
     */
48
    public function getPrototype(): AbstractPrototype
49
    {
50
        return $this->prototype;
51
    }
52
}
53