-
Notifications
You must be signed in to change notification settings - Fork 13
/
EmbeddingTest.php
75 lines (60 loc) · 1.82 KB
/
EmbeddingTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
declare(strict_types=1);
namespace Shoot\Shoot\Tests\Integration\Embedding;
use PHPUnit\Framework\MockObject\MockObject;
use Shoot\Shoot\PresenterInterface;
use Shoot\Shoot\Tests\Integration\IntegrationTestCase;
final class EmbeddingTest extends IntegrationTestCase
{
/** @var PresenterInterface|MockObject */
private $pagePresenter;
/** @var string */
protected $templateDirectory = __DIR__ . '/Templates';
/**
* @return void
*/
protected function setUp()
{
$this->pagePresenter = $this->createMock(PresenterInterface::class);
$this->pagePresenter
->method('present')
->will($this->returnArgument(1));
$this->addToContainer('PagePresenter', $this->pagePresenter);
parent::setUp();
}
/**
* @return void
*/
public function testEmbeddedTemplatesShouldHaveTheirPresentersInvoked()
{
$output = $this->renderTemplate('page.twig');
$this->assertContains('<li><a href="/">Home</a></li>', $output);
}
/**
* @return void
*/
public function testOverriddenBlocksShouldReceiveVariablesFromParent()
{
$output = $this->renderTemplate('page.twig');
$this->assertContains('<h1>page_title</h1>', $output);
$this->assertContains('<p>page_content</p>', $output);
}
/**
* @return void
*/
public function testEmbeddedTemplatesShouldReceiveVariablesPassedAsArguments()
{
$output = $this->renderTemplate('page.twig');
$this->assertContains('<main class="main--overriden">', $output);
}
/**
* @return void
*/
public function testPresentersShouldOnlyBeCalledOnce()
{
$this->pagePresenter
->expects($this->once())
->method('present');
$this->renderTemplate('page.twig');
}
}