Passed
Branch master (4bec7e)
by Stanislau
32:39 queued 29:56
created

LocatorCachedTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
eloc 19
dl 0
loc 30
rs 10
c 1
b 1
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A testLookup() 0 28 3
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 *  This file is part of the Micro framework package.
7
 *
8
 *  (c) Stanislau Komar <[email protected]>
9
 *
10
 *  For the full copyright and license information, please view the LICENSE
11
 *  file that was distributed with this source code.
12
 */
13
14
namespace Micro\Plugin\Locator\Test\Unit\Locator;
15
16
use Micro\Plugin\Locator\Locator\Locator;
17
use Micro\Plugin\Locator\Locator\LocatorCached;
18
use Micro\Plugin\Locator\Locator\LocatorInterface;
19
use PHPUnit\Framework\TestCase;
20
21
class LocatorCachedTest extends TestCase
22
{
23
    public function testLookup()
24
    {
25
        $acceptedRes = [
26
            \stdClass::class,
27
            Locator::class,
28
        ];
29
30
        $decorated = $this->createMock(LocatorInterface::class);
31
        $decorated->expects($this->once())->method('lookup')->with(
32
            \stdClass::class
33
        )->willReturn(new \ArrayObject($acceptedRes));
34
35
        $locatorCached = new LocatorCached($decorated);
36
        $it1 = $locatorCached->lookup(\stdClass::class);
37
        $results1 = [];
38
        foreach ($it1 as $class) {
39
            $results1[] = $class;
40
        }
41
42
        $this->assertEquals($acceptedRes, $results1);
43
44
        $results2 = [];
45
        $it2 = $locatorCached->lookup(\stdClass::class);
46
        foreach ($it2 as $class) {
47
            $results2[] = $class;
48
        }
49
50
        $this->assertEquals($acceptedRes, $results2);
51
    }
52
}
53