‪TYPO3CMS  10.4
NewRecordViewHelperTest.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\FunctionalTestCase;
23 
27 class ‪NewRecordViewHelperTest extends FunctionalTestCase
28 {
33  {
34  $view = GeneralUtility::makeInstance(StandaloneView::class);
35  $view->setTemplatePathAndFilename('EXT:backend/Tests/Functional/ViewHelpers/Fixtures/Link/NewRecordViewHelper/WithPidAndTable.html');
36  $result = urldecode($view->render());
37 
38  self::assertStringContainsString('route=/record/edit', $result);
39  self::assertStringContainsString('edit[a_table][17]=new', $result);
40  }
41 
46  {
47  $view = GeneralUtility::makeInstance(StandaloneView::class);
48  $view->setTemplatePathAndFilename('EXT:backend/Tests/Functional/ViewHelpers/Fixtures/Link/NewRecordViewHelper/WithTable.html');
49  $result = urldecode($view->render());
50 
51  self::assertStringContainsString('route=/record/edit', $result);
52  self::assertStringContainsString('edit[a_table][0]=new', $result);
53  }
54 
59  {
60  $view = GeneralUtility::makeInstance(StandaloneView::class);
61  $view->setTemplatePathAndFilename('EXT:backend/Tests/Functional/ViewHelpers/Fixtures/Link/NewRecordViewHelper/InlineWithPidAndTable.html');
62  $result = urldecode($view->render());
63 
64  self::assertStringContainsString('route=/record/edit', $result);
65  self::assertStringContainsString('edit[b_table][17]=new', $result);
66  }
67 
72  {
73  $view = GeneralUtility::makeInstance(StandaloneView::class);
74  $view->setTemplatePathAndFilename('EXT:backend/Tests/Functional/ViewHelpers/Fixtures/Link/NewRecordViewHelper/WithPidTableAndReturnUrl.html');
75  $result = urldecode($view->render());
76 
77  self::assertStringContainsString('route=/record/edit', $result);
78  self::assertStringContainsString('edit[c_table][17]=new', $result);
79  self::assertStringContainsString('returnUrl=foo/bar', $result);
80  }
81 
86  {
87  $view = GeneralUtility::makeInstance(StandaloneView::class);
88  $view->setTemplatePathAndFilename('EXT:backend/Tests/Functional/ViewHelpers/Fixtures/Link/NewRecordViewHelper/WithNegativeUid.html');
89  $result = urldecode($view->render());
90 
91  self::assertStringContainsString('route=/record/edit', $result);
92  self::assertStringContainsString('edit[c_table][-11]=new', $result);
93  }
94 
99  {
100  $this->expectException(\InvalidArgumentException::class);
101  $this->expectExceptionCode(1526129969);
102 
103  $view = GeneralUtility::makeInstance(StandaloneView::class);
104  $view->setTemplatePathAndFilename('EXT:backend/Tests/Functional/ViewHelpers/Fixtures/Link/NewRecordViewHelper/WithUidAndPid.html');
105  $view->render();
106  }
107 
112  {
113  $this->expectException(\InvalidArgumentException::class);
114  $this->expectExceptionCode(1526134901);
115 
116  $view = GeneralUtility::makeInstance(StandaloneView::class);
117  $view->setTemplatePathAndFilename('EXT:backend/Tests/Functional/ViewHelpers/Fixtures/Link/NewRecordViewHelper/WithPositiveUid.html');
118  $view->render();
119  }
120 }
‪TYPO3\CMS\Fluid\View\StandaloneView
Definition: StandaloneView.php:34
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46