-
Notifications
You must be signed in to change notification settings - Fork 82
Expand file tree
/
Copy pathDefaultLanguageTest.php
More file actions
133 lines (124 loc) · 5.98 KB
/
DefaultLanguageTest.php
File metadata and controls
133 lines (124 loc) · 5.98 KB
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
<?php
namespace B13\Container\Tests\Functional\Frontend;
/*
* This file is part of TYPO3 CMS-based extension "container" by b13.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*/
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\Attributes\Test;
use TYPO3\CMS\Core\Information\Typo3Version;
use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalRequest;
class DefaultLanguageTest extends AbstractFrontend
{
#[Test]
#[Group('frontend')]
public function childrenAreRendered(): void
{
$this->importCSVDataSet(__DIR__ . '/Fixtures/default_language.csv');
$this->setUpFrontendRootPage(
1,
[
'constants' => ['EXT:container/Tests/Functional/Frontend/Fixtures/TypoScript/constants.typoscript'],
'setup' => ['EXT:container/Tests/Functional/Frontend/Fixtures/TypoScript/setup.typoscript'],
]
);
$response = $this->executeFrontendRequestWrapper(new InternalRequest('http://localhost/'));
$body = (string)$response->getBody();
$body = $this->prepareContent($body);
self::assertStringContainsString('<h1 class="container">container-default</h1>', $body);
self::assertStringContainsString('<h6 class="header-children">header-default</h6>', $body);
self::assertStringContainsString('<h6 class="left-children">left-side-default</h6>', $body);
// rendered content
self::assertStringContainsString('<h2 class="">header-default</h2>', $body);
self::assertStringContainsString('<h2 class="">left-side-default</h2>', $body);
}
#[Test]
#[Group('frontend')]
public function childrenAreRenderedContentArea(): void
{
if (((float)(new Typo3Version())->getBranch()) < 14.2) {
$this->markTestSkipped('Content area rendering is only supported in TYPO3 v14.2 and above');
}
$this->importCSVDataSet(__DIR__ . '/Fixtures/default_language_ContentArea.csv');
$this->setUpFrontendRootPage(
1,
[
'constants' => ['EXT:container/Tests/Functional/Frontend/Fixtures/TypoScript/constants.typoscript'],
'setup' => [
'EXT:container/Tests/Functional/Frontend/Fixtures/TypoScript/setup.typoscript',
'EXT:container_example/Configuration/Sets/ContainerExample/TypoScript/2ColsContentArea/setup.typoscript',
],
]
);
$response = $this->executeFrontendRequestWrapper(new InternalRequest('http://localhost/'));
$body = (string)$response->getBody();
$body = $this->prepareContent($body);
// rendered content
self::assertStringContainsString('<h2 class="">left-side-default</h2>', $body);
self::assertStringContainsString('<h2 class="">right-side-default</h2>', $body);
}
#[Test]
#[Group('frontend')]
public function childrenAreRenderedAsSorted(): void
{
$this->importCSVDataSet(__DIR__ . '/Fixtures/ContainerWithTwoChildren.csv');
$this->setUpFrontendRootPage(
1,
[
'constants' => ['EXT:container/Tests/Functional/Frontend/Fixtures/TypoScript/constants.typoscript'],
'setup' => [
'EXT:container/Tests/Functional/Frontend/Fixtures/TypoScript/setup.typoscript',
'EXT:container/Tests/Functional/Frontend/Fixtures/TypoScript/container_with_two_children.typoscript',
],
]
);
$response = $this->executeFrontendRequestWrapper(new InternalRequest('http://localhost/'));
$body = (string)$response->getBody();
$body = $this->prepareContent($body);
self::assertStringContainsString('<h6>first child</h6><h6>second child</h6>', $body);
}
#[Test]
#[Group('frontend')]
public function canRenderContainerFromOtherPage(): void
{
$this->importCSVDataSet(__DIR__ . '/Fixtures/ContainerFromOtherPage.csv');
$this->setUpFrontendRootPage(
1,
[
'constants' => ['EXT:container/Tests/Functional/Frontend/Fixtures/TypoScript/constants.typoscript'],
'setup' => [
'EXT:container/Tests/Functional/Frontend/Fixtures/TypoScript/container_from_other_page.typoscript',
],
]
);
$response = $this->executeFrontendRequestWrapper(new InternalRequest('http://localhost/'));
$body = (string)$response->getBody();
$body = $this->prepareContent($body);
self::assertStringContainsString('<h2>left side (201)</h2><div class="left-children"><h6 class="left-children">child</h6><div id="c2"', $body);
}
#[Test]
#[Group('frontend')]
public function childrenAreNotRenderedIfSkipOptionIsSet(): void
{
$this->importCSVDataSet(__DIR__ . '/Fixtures/default_language.csv');
$this->setUpFrontendRootPage(
1,
[
'constants' => ['EXT:container/Tests/Functional/Frontend/Fixtures/TypoScript/constants.typoscript'],
'setup' => ['EXT:container/Tests/Functional/Frontend/Fixtures/TypoScript/setup_skip_rendering_child_content.typoscript'],
]
);
$response = $this->executeFrontendRequestWrapper(new InternalRequest('http://localhost/'));
$body = (string)$response->getBody();
$body = $this->prepareContent($body);
self::assertStringContainsString('<h1 class="container">container-default</h1>', $body);
self::assertStringContainsString('<h6 class="header-children">header-default</h6>', $body);
self::assertStringContainsString('<h6 class="left-children">left-side-default</h6>', $body);
// rendered content
self::assertStringNotContainsString('<h2 class="">header-default</h2>', $body);
self::assertStringNotContainsString('<h2 class="">left-side-default</h2>', $body);
}
}