FrontMatterFilterTest::setUp()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
/*
4
 * This is part of the webuni/front-matter package.
5
 *
6
 * (c) Martin Hasoň <[email protected]>
7
 * (c) Webuni s.r.o. <[email protected]>
8
 *
9
 * For the full copyright and license information, please view the LICENSE
10
 * file that was distributed with this source code.
11
 */
12
13
namespace Webuni\FrontMatter\Tests\Haml;
14
15
use MtHaml\Filter\FilterInterface;
16
use MtHaml\Node\Filter;
17
use MtHaml\NodeVisitor\RendererAbstract;
18
use PHPUnit\Framework\TestCase;
19
use Webuni\FrontMatter\Document;
20
use Webuni\FrontMatter\FrontMatterInterface;
21
use Webuni\FrontMatter\Haml\FrontMatterFilter;
22
23
class FrontMatterFilterTest extends TestCase
24
{
25
    private $frontMatter;
26
    private $originalFilter;
27
    private $filter;
28
29
    protected function setUp(): void
30
    {
31
        $this->frontMatter = $this->createMock(FrontMatterInterface::class);
32
        $this->originalFilter = $this->createMock(FilterInterface::class);
33
        $this->filter = new FrontMatterFilter($this->frontMatter, $this->originalFilter);
34
    }
35
36 View Code Duplication
    public function testIsOptimizable()
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...
37
    {
38
        $renderer = $this->createMock(RendererAbstract::class);
39
        $node = $this->createMock(Filter::class);
40
41
        $this->originalFilter->method('isOptimizable')->with($renderer, $node, $options = [])->willReturn(true);
42
        $this->assertTrue($this->filter->isOptimizable($renderer, $node, $options));
43
    }
44
45 View Code Duplication
    public function testOptimize()
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...
46
    {
47
        $renderer = $this->createMock(RendererAbstract::class);
48
        $node = $this->createMock(Filter::class);
49
50
        $this->originalFilter->method('optimize')->with($renderer, $node, $options = [])->willReturn('foo');
51
        $this->assertEquals('foo', $this->filter->optimize($renderer, $node, $options));
52
    }
53
54
    public function testFilter()
55
    {
56
        $document = new Document('');
57
58
        $this->frontMatter->method('parse')->with($content = "---\n----\nstring")->willReturn($document);
59
        $this->originalFilter->method('filter')->with($document, $context = [], $options = [])->willReturn('string');
60
61
        $this->assertEquals($document, $this->filter->filter($content, $context, $options));
62
    }
63
}
64