‪TYPO3CMS  11.5
TypolinkViewHelperTest.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
22 use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalRequest;
23 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
24 
25 class ‪TypolinkViewHelperTest extends FunctionalTestCase
26 {
28 
32  protected const ‪LANGUAGE_PRESETS = [
33  'EN' => ['id' => 0, 'title' => 'English', 'locale' => 'en_US.UTF8'],
34  ];
35 
37  'FE' => [
38  'cacheHash' => [
39  'enforceValidation' => false,
40  ],
41  ],
42  ];
43 
44  protected function ‪setUp(): void
45  {
46  parent::setUp();
47  $this->importCSVDataSet(__DIR__ . '/../../Fixtures/pages.csv');
49  'test',
50  $this->‪buildSiteConfiguration(1, '/'),
51  [
52  $this->‪buildDefaultLanguageConfiguration('EN', '/en/'),
53  ]
54  );
55  }
56 
57  public function ‪renderDataProvider(): array
58  {
59  return [
60  'uri: default' => [
61  '<f:uri.typolink parameter="1" />',
62  '/en/',
63  ],
64  'uri: with add query string' => [
65  '<f:uri.typolink parameter="1" addQueryString="true" />',
66  '/en/?foo=bar&amp;temp=test&amp;cHash=286759dfcd3f566fa21091a0d77e9831',
67  ],
68  'uri: with add query string and exclude' => [
69  '<f:uri.typolink parameter="1" addQueryString="true" addQueryStringExclude="temp" />',
70  '/en/?foo=bar&amp;cHash=afa4b37588ab917af3cfe2cd4464029d',
71  ],
72  't3://url uri: default' => [
73  '<f:uri.typolink parameter="t3://url?url=https://example.org?param=1&other=dude" />',
74  'https://example.org?param=1',
75  ],
76  't3://url uri: with add query string' => [
77  '<f:uri.typolink parameter="t3://url?url=https://example.org?param=1&other=dude" addQueryString="true" />',
78  'https://example.org?param=1',
79  ],
80  't3://url uri: with add query string and exclude' => [
81  '<f:uri.typolink parameter="t3://url?url=https://example.org?param=1&other=dude" addQueryString="true" addQueryStringExclude="temp" />',
82  'https://example.org?param=1',
83  ],
84  'mailto: uri: default' => [
85  '<f:uri.typolink parameter="mailto:foo@typo3.org" />',
86  'mailto:foo@typo3.org',
87  ],
88  'mailto: uri: with add query string' => [
89  '<f:uri.typolink parameter="mailto:foo@typo3.org" addQueryString="true" />',
90  'mailto:foo@typo3.org',
91  ],
92  'mailto: uri: with add query string and exclude' => [
93  '<f:uri.typolink parameter="mailto:foo@typo3.org" addQueryString="true" addQueryStringExclude="temp" />',
94  'mailto:foo@typo3.org',
95  ],
96  'http://: uri: default' => [
97  '<f:uri.typolink parameter="http://typo3.org/foo/?foo=bar" />',
98  'http://typo3.org/foo/?foo=bar',
99  ],
100  'http://: uri: with add query string' => [
101  '<f:uri.typolink parameter="http://typo3.org/foo/?foo=bar" addQueryString="true" />',
102  'http://typo3.org/foo/?foo=bar',
103  ],
104  'http://: uri: with add query string and exclude' => [
105  '<f:uri.typolink parameter="http://typo3.org/foo/?foo=bar" addQueryString="true" addQueryStringExclude="temp" />',
106  'http://typo3.org/foo/?foo=bar',
107  ],
108  ];
109  }
110 
115  public function ‪render(string $template, string $expected): void
116  {
117  (new ‪ConnectionPool())->getConnectionForTable('sys_template')->insert('sys_template', [
118  'pid' => 1,
119  'root' => 1,
120  'clear' => 1,
121  'config' => <<<EOT
122 page = PAGE
123 page.10 = FLUIDTEMPLATE
124 page.10 {
125  template = TEXT
126  template.value = $template
127 }
128 EOT
129  ]);
130  $response = $this->executeFrontendSubRequest(
131  (new InternalRequest())
132  ->withPageId(1)
133  ->withQueryParameter('foo', 'bar')
134  ->withQueryParameter('temp', 'test')
135  );
136  self::assertStringContainsString($expected, (string)$response->getBody());
137  }
138 }
‪TYPO3\CMS\Core\Tests\Functional\SiteHandling\SiteBasedTestTrait
Definition: SiteBasedTestTrait.php:36
‪TYPO3\CMS\Core\Tests\Functional\SiteHandling\SiteBasedTestTrait\writeSiteConfiguration
‪writeSiteConfiguration(string $identifier, array $site=[], array $languages=[], array $errorHandling=[])
Definition: SiteBasedTestTrait.php:58
‪TYPO3\CMS\Core\Tests\Functional\SiteHandling\SiteBasedTestTrait\buildDefaultLanguageConfiguration
‪array buildDefaultLanguageConfiguration(string $identifier, string $base)
Definition: SiteBasedTestTrait.php:126
‪TYPO3\CMS\Fluid\Tests\Functional\ViewHelpers\Uri
Definition: ExternalViewHelperTest.php:18
‪TYPO3\CMS\Core\Tests\Functional\SiteHandling\SiteBasedTestTrait\buildSiteConfiguration
‪array buildSiteConfiguration(int $rootPageId, string $base='')
Definition: SiteBasedTestTrait.php:111
‪TYPO3\CMS\Core\Database\ConnectionPool
Definition: ConnectionPool.php:46