‪TYPO3CMS  11.5
ShortcutControllerTest.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 
24 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
25 
26 class ‪ShortcutControllerTest extends FunctionalTestCase
27 {
30 
31  protected function ‪setUp(): void
32  {
33  parent::setUp();
34 
35  $this->importCSVDataSet(__DIR__ . '/../Fixtures/sys_be_shortcuts.csv');
36 
37  $this->setUpBackendUserFromFixture(1);
39 
40  $this->subject = new ‪ShortcutController();
41  $this->request = (new ‪ServerRequest())->withAttribute('normalizedParams', new ‪NormalizedParams([], [], '', ''));
42  }
43 
52  public function ‪addShortcutTest(array $parsedBody, array $queryParams, string $expectedResponseBody): void
53  {
54  ‪$request = $this->request->‪withParsedBody($parsedBody)->withQueryParams($queryParams);
55  self::assertEquals($expectedResponseBody, $this->subject->addAction(‪$request)->getBody());
56  }
57 
58  public function ‪addShortcutTestDataProvide(): \Generator
59  {
60  yield 'No route defined' => [
61  [],
62  [],
63  'missingRoute',
64  ];
65  yield 'Existing data as parsed body' => [
66  [
67  'routeIdentifier' => 'web_layout',
68  'arguments' => '{"id":"123"}',
69  ],
70  [],
71  'alreadyExists',
72  ];
73  yield 'Existing data as query parameters' => [
74  [],
75  [
76  'routeIdentifier' => 'web_layout',
77  'arguments' => '{"id":"123"}',
78  ],
79  'alreadyExists',
80  ];
81  yield 'Invalid route identifier' => [
82  [],
83  [
84  'routeIdentifier' => 'invalid_route_identifier',
85  ],
86  'failed',
87  ];
88  yield 'New data as parsed body' => [
89  [
90  'routeIdentifier' => 'web_list',
91  'arguments' => '{"id":"123","GET":{"clipBoard":"1"}}',
92  ],
93  [],
94  'success',
95  ];
96  yield 'New data as query parameters' => [
97  [],
98  [
99  'routeIdentifier' => 'web_list',
100  'arguments' => '{"id":"321","GET":{"clipBoard":"1"}}',
101  ],
102  'success',
103  ];
104  }
105 }
‪TYPO3\CMS\Backend\Controller\ShortcutController
Definition: ShortcutController.php:37
‪TYPO3\CMS\Backend\Tests\Functional\Controller\ShortcutControllerTest\addShortcutTestDataProvide
‪addShortcutTestDataProvide()
Definition: ShortcutControllerTest.php:58
‪TYPO3\CMS\Backend\Tests\Functional\Controller\ShortcutControllerTest\$subject
‪ShortcutController $subject
Definition: ShortcutControllerTest.php:28
‪TYPO3\CMS\Core\Core\Bootstrap\initializeLanguageObject
‪static initializeLanguageObject()
Definition: Bootstrap.php:598
‪TYPO3\CMS\Backend\Tests\Functional\Controller\ShortcutControllerTest\addShortcutTest
‪addShortcutTest(array $parsedBody, array $queryParams, string $expectedResponseBody)
Definition: ShortcutControllerTest.php:52
‪TYPO3\CMS\Core\Http\ServerRequest
Definition: ServerRequest.php:37
‪TYPO3\CMS\Backend\Tests\Functional\Controller\ShortcutControllerTest
Definition: ShortcutControllerTest.php:27
‪TYPO3\CMS\Core\Http\ServerRequest\withParsedBody
‪static withParsedBody($data)
Definition: ServerRequest.php:268
‪TYPO3\CMS\Core\Core\Bootstrap
Definition: Bootstrap.php:70
‪TYPO3\CMS\Backend\Tests\Functional\Controller\ShortcutControllerTest\setUp
‪setUp()
Definition: ShortcutControllerTest.php:31
‪TYPO3\CMS\Backend\Tests\Functional\Controller
Definition: EditDocumentControllerTest.php:18
‪TYPO3\CMS\Core\Http\NormalizedParams
Definition: NormalizedParams.php:35
‪TYPO3\CMS\Backend\Tests\Functional\Controller\ShortcutControllerTest\$request
‪ServerRequest $request
Definition: ShortcutControllerTest.php:29