‪TYPO3CMS  9.5
NewRecordViewHelperTest.php
Go to the documentation of this file.
1 <?php
2 declare(strict_types = 1);
3 
5 
6 /*
7  * This file is part of the TYPO3 CMS project.
8  *
9  * It is free software; you can redistribute it and/or modify it under
10  * the terms of the GNU General Public License, either version 2
11  * of the License, or any later version.
12  *
13  * For the full copyright and license information, please read the
14  * LICENSE.txt file that was distributed with this source code.
15  *
16  * The TYPO3 project - inspiring people to share!
17  */
18 
21 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
22 
26 class ‪NewRecordViewHelperTest extends FunctionalTestCase
27 {
32  {
33  $view = GeneralUtility::makeInstance(StandaloneView::class);
34  $view->setTemplatePathAndFilename('EXT:backend/Tests/Functional/ViewHelpers/Fixtures/Link/NewRecordViewHelper/WithPidAndTable.html');
35  $result = urldecode($view->render());
36 
37  $this->assertContains('route=/record/edit', $result);
38  $this->assertContains('edit[a_table][17]=new', $result);
39  }
40 
45  {
46  $view = GeneralUtility::makeInstance(StandaloneView::class);
47  $view->setTemplatePathAndFilename('EXT:backend/Tests/Functional/ViewHelpers/Fixtures/Link/NewRecordViewHelper/WithTable.html');
48  $result = urldecode($view->render());
49 
50  $this->assertContains('route=/record/edit', $result);
51  $this->assertContains('edit[a_table][0]=new', $result);
52  }
53 
58  {
59  $view = GeneralUtility::makeInstance(StandaloneView::class);
60  $view->setTemplatePathAndFilename('EXT:backend/Tests/Functional/ViewHelpers/Fixtures/Link/NewRecordViewHelper/InlineWithPidAndTable.html');
61  $result = urldecode($view->render());
62 
63  $this->assertContains('route=/record/edit', $result);
64  $this->assertContains('edit[b_table][17]=new', $result);
65  }
66 
71  {
72  $view = GeneralUtility::makeInstance(StandaloneView::class);
73  $view->setTemplatePathAndFilename('EXT:backend/Tests/Functional/ViewHelpers/Fixtures/Link/NewRecordViewHelper/WithPidTableAndReturnUrl.html');
74  $result = urldecode($view->render());
75 
76  $this->assertContains('route=/record/edit', $result);
77  $this->assertContains('edit[c_table][17]=new', $result);
78  $this->assertContains('returnUrl=foo/bar', $result);
79  }
80 
85  {
86  $view = GeneralUtility::makeInstance(StandaloneView::class);
87  $view->setTemplatePathAndFilename('EXT:backend/Tests/Functional/ViewHelpers/Fixtures/Link/NewRecordViewHelper/WithNegativeUid.html');
88  $result = urldecode($view->render());
89 
90  $this->assertContains('route=/record/edit', $result);
91  $this->assertContains('edit[c_table][-11]=new', $result);
92  }
93 
98  {
99  $this->expectException(\InvalidArgumentException::class);
100  $this->expectExceptionCode(1526129969);
101 
102  $view = GeneralUtility::makeInstance(StandaloneView::class);
103  $view->setTemplatePathAndFilename('EXT:backend/Tests/Functional/ViewHelpers/Fixtures/Link/NewRecordViewHelper/WithUidAndPid.html');
104  $view->render();
105  }
106 
111  {
112  $this->expectException(\InvalidArgumentException::class);
113  $this->expectExceptionCode(1526134901);
114 
115  $view = GeneralUtility::makeInstance(StandaloneView::class);
116  $view->setTemplatePathAndFilename('EXT:backend/Tests/Functional/ViewHelpers/Fixtures/Link/NewRecordViewHelper/WithPositiveUid.html');
117  $view->render();
118  }
119 }
‪TYPO3\CMS\Fluid\View\StandaloneView
Definition: StandaloneView.php:32
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45