‪TYPO3CMS  11.5
EditRecordViewHelperTest.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 
25 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
26 
27 class ‪EditRecordViewHelperTest extends FunctionalTestCase
28 {
32  protected ‪$initializeDatabase = false;
33 
34  public function ‪setUp(): void
35  {
36  parent::setUp();
37  ‪$GLOBALS['TYPO3_REQUEST'] = (new ‪ServerRequest('https://www.example.com/'))
38  ->withAttribute('applicationType', ‪SystemEnvironmentBuilder::REQUESTTYPE_BE)
39  ->withAttribute('normalizedParams', new ‪NormalizedParams([], [], '', ''));
40  }
41 
45  public function ‪renderReturnsValidLinkInExplicitFormat(): void
46  {
47  $view = GeneralUtility::makeInstance(StandaloneView::class);
48  $view->setTemplatePathAndFilename('EXT:backend/Tests/Functional/ViewHelpers/Fixtures/Link/EditRecordViewHelper/WithUidAndTable.html');
49  $result = urldecode($view->render());
50 
51  self::assertStringContainsString('/typo3/record/edit', $result);
52  self::assertStringContainsString('edit[a_table][42]=edit', $result);
53  }
54 
58  public function ‪renderReturnsValidLinkInInlineFormat(): void
59  {
60  $view = GeneralUtility::makeInstance(StandaloneView::class);
61  $view->setTemplatePathAndFilename('EXT:backend/Tests/Functional/ViewHelpers/Fixtures/Link/EditRecordViewHelper/InlineWithUidAndTable.html');
62  $result = urldecode($view->render());
63 
64  self::assertStringContainsString('/typo3/record/edit', $result);
65  self::assertStringContainsString('edit[b_table][21]=edit', $result);
66  }
67 
71  public function ‪renderReturnsValidLinkWithReturnUrl(): void
72  {
73  $view = GeneralUtility::makeInstance(StandaloneView::class);
74  $view->setTemplatePathAndFilename('EXT:backend/Tests/Functional/ViewHelpers/Fixtures/Link/EditRecordViewHelper/WithUidTableAndReturnUrl.html');
75  $result = urldecode($view->render());
76 
77  self::assertStringContainsString('/typo3/record/edit', $result);
78  self::assertStringContainsString('edit[c_table][43]=edit', $result);
79  self::assertStringContainsString('returnUrl=foo/bar', $result);
80  }
81 
85  public function ‪renderReturnsValidLinkWithField(): void
86  {
87  $view = GeneralUtility::makeInstance(StandaloneView::class);
88  $view->setTemplatePathAndFilename('EXT:backend/Tests/Functional/ViewHelpers/Fixtures/Link/EditRecordViewHelper/WithUidTableAndField.html');
89  $result = urldecode($view->render());
90 
91  self::assertStringContainsString('/typo3/record/edit', $result);
92  self::assertStringContainsString('edit[c_table][43]=edit', $result);
93  self::assertStringContainsString('columnsOnly=canonical_url', $result);
94  }
95 
99  public function ‪renderReturnsValidLinkWithFields(): void
100  {
101  $view = GeneralUtility::makeInstance(StandaloneView::class);
102  $view->setTemplatePathAndFilename('EXT:backend/Tests/Functional/ViewHelpers/Fixtures/Link/EditRecordViewHelper/WithUidTableAndFields.html');
103  $result = urldecode($view->render());
104 
105  self::assertStringContainsString('/typo3/record/edit', $result);
106  self::assertStringContainsString('edit[c_table][43]=edit', $result);
107  self::assertStringContainsString('columnsOnly=canonical_url,title', $result);
108  }
109 
113  public function ‪renderThrowsExceptionForInvalidUidArgument(): void
114  {
115  $this->expectException(\InvalidArgumentException::class);
116  $this->expectExceptionCode(1526127158);
117 
118  $view = GeneralUtility::makeInstance(StandaloneView::class);
119  $view->setTemplatePathAndFilename('EXT:backend/Tests/Functional/ViewHelpers/Fixtures/Link/EditRecordViewHelper/WithNegativeUid.html');
120  $view->render();
121  }
122 }
‪TYPO3\CMS\Core\Core\SystemEnvironmentBuilder
Definition: SystemEnvironmentBuilder.php:41
‪TYPO3\CMS\Core\Core\SystemEnvironmentBuilder\REQUESTTYPE_BE
‪const REQUESTTYPE_BE
Definition: SystemEnvironmentBuilder.php:45
‪TYPO3\CMS\Core\Http\ServerRequest
Definition: ServerRequest.php:37
‪TYPO3\CMS\Fluid\View\StandaloneView
Definition: StandaloneView.php:31
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:50
‪TYPO3\CMS\Core\Http\NormalizedParams
Definition: NormalizedParams.php:35