Completed
Push — master ( dfede2...367c5a )
by Martin
03:32
created

FrontMatterFilterTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

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