EmbeddingTest   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
eloc 21
c 1
b 0
f 0
dl 0
loc 48
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A testEmbeddedTemplatesShouldReceiveVariablesPassedAsArguments() 0 5 1
A testOverriddenBlocksShouldReceiveVariablesFromParent() 0 7 1
A testPresentersShouldOnlyBeCalledOnce() 0 7 1
A testEmbeddedTemplatesShouldHaveTheirPresentersInvoked() 0 5 1
A setUp() 0 11 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Shoot\Shoot\Tests\Integration\Embedding;
5
6
use PHPUnit\Framework\MockObject\MockObject;
7
use Shoot\Shoot\PresenterInterface;
8
use Shoot\Shoot\Tests\Integration\IntegrationTestCase;
9
10
final class EmbeddingTest extends IntegrationTestCase
11
{
12
    /** @var PresenterInterface|MockObject */
13
    private $pagePresenter;
14
15
    protected function setUp(): void
16
    {
17
        $this->pagePresenter = $this->createMock(PresenterInterface::class);
18
        $this->pagePresenter
19
            ->method('present')
20
            ->will($this->returnArgument(1));
21
22
        $this->addToContainer('PagePresenter', $this->pagePresenter);
23
        $this->setTemplateDirectory(__DIR__ . '/Templates');
24
25
        parent::setUp();
26
    }
27
28
    public function testEmbeddedTemplatesShouldHaveTheirPresentersInvoked(): void
29
    {
30
        $output = $this->renderTemplate('page.twig');
31
32
        $this->assertContains('<li><a href="/">Home</a></li>', $output);
33
    }
34
35
    public function testOverriddenBlocksShouldReceiveVariablesFromParent(): void
36
    {
37
        $output = $this->renderTemplate('page.twig');
38
39
        $this->assertContains('<title>page_title</title>', $output);
40
        $this->assertContains('<h1>page_title</h1>', $output);
41
        $this->assertContains('<p>page_content</p>', $output);
42
    }
43
44
    public function testEmbeddedTemplatesShouldReceiveVariablesPassedAsArguments(): void
45
    {
46
        $output = $this->renderTemplate('page.twig');
47
48
        $this->assertContains('<main class="main--overriden">', $output);
49
    }
50
51
    public function testPresentersShouldOnlyBeCalledOnce(): void
52
    {
53
        $this->pagePresenter
54
            ->expects($this->once())
55
            ->method('present');
56
57
        $this->renderTemplate('page.twig');
58
    }
59
}
60