Completed
Push — master ( 096d68...0c8b52 )
by Korotkov
01:11 queued 10s
created

PrototypeTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 35
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testCountInstances() 0 7 1
A setUp() 0 3 1
A testInstances() 0 5 1
A getPrototype() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * @author    : Korotkov Danila <[email protected]>
7
 * @copyright Copyright (c) 2018, Korotkov Danila
8
 * @license   http://www.gnu.org/licenses/gpl.html GNU GPLv3.0
9
 */
10
11
use PHPUnit\Framework\TestCase as PHPUnit_Framework_TestCase;
0 ignored issues
show
Bug introduced by
The type PHPUnit\Framework\TestCase was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
12
use Creational\Prototype\Prototype;
13
use Creational\Prototype\FirstPrototype;
14
15
16
/**
17
 * Class PrototypeTest
18
 */
19
class PrototypeTest extends PHPUnit_Framework_TestCase
20
{
21
22
    /**
23
     * @var
24
     */
25
    protected $prototype;
26
27
    protected function setUp(): void
28
    {
29
        $this->prototype = new FirstPrototype();
30
    }
31
32
    public function testInstances()
33
    {
34
        $clonedFirstPrototype = $this->getPrototype()->getPrototype();
35
        $this->assertFalse($clonedFirstPrototype === $this->getPrototype());
36
        $this->assertInstanceOf(FirstPrototype::class, $clonedFirstPrototype);
37
    }
38
39
    public function testCountInstances()
40
    {
41
        $this->assertEquals(Prototype::$count, 1);
42
        $this->getPrototype()->getPrototype();
43
        $this->assertEquals(Prototype::$count, 2);
44
        $this->getPrototype()->getPrototype();
45
        $this->assertEquals(Prototype::$count, 3);
46
    }
47
48
    /**
49
     * @return mixed
50
     */
51
    public function getPrototype()
52
    {
53
        return $this->prototype;
54
    }
55
}
56