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 | /** @var string */ |
||||||
16 | protected $templateDirectory = __DIR__ . '/Templates'; |
||||||
17 | |||||||
18 | protected function setUp(): void |
||||||
19 | { |
||||||
20 | $this->pagePresenter = $this->createMock(PresenterInterface::class); |
||||||
21 | $this->pagePresenter |
||||||
22 | ->method('present') |
||||||
0 ignored issues
–
show
|
|||||||
23 | ->will($this->returnArgument(1)); |
||||||
24 | |||||||
25 | $this->addToContainer('PagePresenter', $this->pagePresenter); |
||||||
26 | |||||||
27 | parent::setUp(); |
||||||
28 | } |
||||||
29 | |||||||
30 | public function testEmbeddedTemplatesShouldHaveTheirPresentersInvoked(): void |
||||||
31 | { |
||||||
32 | $output = $this->renderTemplate('page.twig'); |
||||||
33 | |||||||
34 | $this->assertContains('<li><a href="/">Home</a></li>', $output); |
||||||
35 | } |
||||||
36 | |||||||
37 | public function testOverriddenBlocksShouldReceiveVariablesFromParent(): void |
||||||
38 | { |
||||||
39 | $output = $this->renderTemplate('page.twig'); |
||||||
40 | |||||||
41 | $this->assertContains('<title>page_title</title>', $output); |
||||||
42 | $this->assertContains('<h1>page_title</h1>', $output); |
||||||
43 | $this->assertContains('<p>page_content</p>', $output); |
||||||
44 | } |
||||||
45 | |||||||
46 | public function testEmbeddedTemplatesShouldReceiveVariablesPassedAsArguments(): void |
||||||
47 | { |
||||||
48 | $output = $this->renderTemplate('page.twig'); |
||||||
49 | |||||||
50 | $this->assertContains('<main class="main--overriden">', $output); |
||||||
51 | } |
||||||
52 | |||||||
53 | public function testPresentersShouldOnlyBeCalledOnce(): void |
||||||
54 | { |
||||||
55 | $this->pagePresenter |
||||||
56 | ->expects($this->once()) |
||||||
0 ignored issues
–
show
The method
expects() does not exist on Shoot\Shoot\PresenterInterface .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||||||
57 | ->method('present'); |
||||||
58 | |||||||
59 | $this->renderTemplate('page.twig'); |
||||||
60 | } |
||||||
61 | } |
||||||
62 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.