Passed
Push — master ( 6f30dc...d012e1 )
by Stanislau
02:52
created

TwigTemplatePluginTraitTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 14
c 1
b 0
f 1
dl 0
loc 26
rs 10
wmc 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
testAnonClass() 0 12 ?
A testRealClass() 0 10 1
A hp$0 ➔ testAnonClass() 0 12 1
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\Plugin;
15
16
use Micro\Plugin\Twig\Plugin\TwigTemplatePluginInterface;
17
use Micro\Plugin\Twig\Plugin\TwigTemplatePluginTrait;
18
use PHPUnit\Framework\TestCase;
19
20
class TwigTemplatePluginTraitTest extends TestCase
21
{
22
    public function testRealClass()
23
    {
24
        $plugin = new ExampleTwigTemplatePluginTraitTest();
25
26
        $ref = new \ReflectionObject($plugin);
27
28
        $this->assertEquals('ExampleTwigTemplatePluginTraitTest', $plugin->getTwigNamespace());
29
        $this->assertEquals([
30
            \dirname($ref->getFileName()).'/templates',
31
        ], $plugin->getTwigTemplatePaths());
32
    }
33
34
    public function testAnonClass()
35
    {
36
        $plugin = new class() implements TwigTemplatePluginInterface {
37
            use TwigTemplatePluginTrait;
38
        };
39
        $ref = new \ReflectionObject($plugin);
40
41
        $this->assertNull($plugin->getTwigNamespace());
42
        $this->assertEquals([
43
            \dirname($ref->getFileName()).'/templates',
44
        ],
45
            $plugin->getTwigTemplatePaths());
46
    }
47
}
48
49
class ExampleTwigTemplatePluginTraitTest implements TwigTemplatePluginInterface
50
{
51
    use TwigTemplatePluginTrait;
52
}
53