Completed
Pull Request — master (#28)
by Jamal
02:52
created

LoaderCollectionTest::testLoadersVisibility()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 6
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
namespace Majora\Framework\Loader\Tests;
4
5
use Majora\Framework\Loader\LoaderCollection;
6
use Majora\Framework\Loader\LoaderInterface;
7
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
8
9
/**
10
 * Class LoaderCollectionTest
11
 *
12
 * @see Majora\Framework\Loader\LoaderCollection
13
 */
14
class LoaderCollectionTest extends \PHPUnit_Framework_TestCase
15
{
16
    public function testLoadersVisibility()
17
    {
18
        $reflection = new \ReflectionProperty(LoaderCollection::class, 'loaders');
19
20
        $this->assertTrue($reflection->isPrivate());
21
    }
22
23 View Code Duplication
    public function testAddLoaderKey()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
24
    {
25
        $loader = $this->prophesize(LoaderInterface::class)->reveal();
26
27
        $collection = new LoaderCollection();
28
        $collection->add('test', $loader);
29
30
        $reflection = new \ReflectionProperty(LoaderCollection::class, 'loaders');
31
        $reflection->setAccessible(true);
32
        $loaders = $reflection->getValue($collection);
33
34
        reset($loaders);
35
36
        $this->assertEquals('test', key($loaders));
37
    }
38
39 View Code Duplication
    public function testAddLoader()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
40
    {
41
        $loader = $this->prophesize(LoaderInterface::class)->reveal();
42
43
        $collection = new LoaderCollection();
44
        $collection->add('test', $loader);
45
46
        $reflection = new \ReflectionProperty(LoaderCollection::class, 'loaders');
47
        $reflection->setAccessible(true);
48
        $loaders = $reflection->getValue($collection);
49
50
        reset($loaders);
51
52
        $this->assertEquals($loader, current($loaders));
53
    }
54
55 View Code Duplication
    public function testHasLoaderPassed()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
56
    {
57
        $loader = $this->prophesize(LoaderInterface::class)->reveal();
58
59
        $collection = new LoaderCollection();
60
        $collection->add('test', $loader);
61
62
        $this->assertTrue($collection->has('test'));
63
    }
64
65 View Code Duplication
    public function testHasLoaderFailed()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
66
    {
67
        $loader = $this->prophesize(LoaderInterface::class)->reveal();
68
69
        $collection = new LoaderCollection();
70
        $collection->add('test', $loader);
71
72
        $this->assertFalse($collection->has('toto'));
73
    }
74
75 View Code Duplication
    public function testGetLoaderPassed()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
76
    {
77
        $loader = $this->prophesize(LoaderInterface::class)->reveal();
78
79
        $collection = new LoaderCollection();
80
        $collection->add('test', $loader);
81
82
        $this->assertEquals($loader, $collection->get('test'));
83
    }
84
85 View Code Duplication
    public function testGetLoaderFailed()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
86
    {
87
        $loader = $this->prophesize(LoaderInterface::class)->reveal();
88
89
        $collection = new LoaderCollection();
90
        $collection->add('test', $loader);
91
        
92
        $this->expectException(\RuntimeException::class);
93
94
        $collection->get('toto');
95
    }
96
}