Passed
Pull Request — master (#3)
by Stanislau
03:00
created

ExtensionLoaderTest::testLoad()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 26
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 16
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 26
rs 9.7333
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\Twig\Test\Unit\Business\Loader;
15
16
use Micro\Plugin\Twig\Business\Loader\ExtensionLoader;
17
use Micro\Plugin\Twig\Plugin\TwigExtensionPluginInterface;
18
use PHPUnit\Framework\TestCase;
19
use Twig\Environment;
20
use Twig\Extension\ExtensionInterface;
21
22
class ExtensionLoaderTest extends TestCase
23
{
24
    public function testLoad()
25
    {
26
        // TwigExtensionPluginInterface
27
        $loader = new ExtensionLoader();
28
        $env = $this->createMock(Environment::class);
29
30
        $objectInvalid = new \stdClass();
31
32
        $loader->load($env, $objectInvalid);
33
34
        $extension = $this->createMock(ExtensionInterface::class);
35
        $objectValid = $this->createMock(TwigExtensionPluginInterface::class);
36
37
        $env
38
            ->expects($this->once())
39
            ->method('addExtension')
40
            ->with($extension);
41
42
        $objectValid
43
            ->expects($this->once())
44
            ->method('provideTwigExtensions')
45
            ->willReturn(new \ArrayObject(
46
                [$extension]
47
            ));
48
49
        $loader->load($env, $objectValid);
50
    }
51
}
52