‪TYPO3CMS  10.4
RedirectModuleCest.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 
20 use Codeception\Example;
22 
27 {
28 
32  public function ‪_before(‪BackendTester $I)
33  {
34  $I->useExistingSession('admin');
35 
36  $I->click('Redirects');
37  $I->switchToContentFrame();
38  $I->canSee('Redirect Management', 'h1');
39  }
40 
45  {
46  $I->amGoingTo('create a new redirects record while none are in the system, yet');
47  $I->canSee('No redirects found!');
48  $I->click('Create new redirect');
49  $I->waitForElementNotVisible('#t3js-ui-block');
50  $I->canSee('Create new Redirect on root level');
51 
52  $I->fillField('//input[contains(@data-formengine-input-name, "data[sys_redirect]") and contains(@data-formengine-input-name, "[source_path]")]', '/my-path/');
53  $I->fillField('//input[contains(@data-formengine-input-name, "data[sys_redirect]") and contains(@data-formengine-input-name, "[target]")]', 1);
54 
55  $saveButtonLink = '//*/button[@name="_savedok"][1]';
56  $I->waitForElement($saveButtonLink, 30);
57  $I->click($saveButtonLink);
58  $I->waitForElementNotVisible('#t3js-ui-block');
59 
60  $I->click('div.module-docheader .btn.t3js-editform-close');
61 
62  $I->waitForElementVisible('table.table-striped');
63  $I->canSee('Redirect Management', 'h1');
64  $I->canSeeNumberOfElements('table.table-striped > tbody > tr', 1);
65  }
66 
71  {
72  $sourceHost = $I->grabTextFrom('table.table-striped > tbody > tr > td:nth-child(1)');
73  $sourcePath = $I->grabTextFrom('table.table-striped > tbody > tr > td:nth-child(2) > a');
74 
75  $I->amGoingTo('test edit on source path');
76  $I->click('table.table-striped > tbody > tr > td:nth-child(2) > a');
77  $this->‪openAndCloseTheEditForm($I, $sourceHost . ', ' . $sourcePath);
78 
79  $I->amGoingTo('test edit on edit button');
80  $I->click('table.table-striped > tbody > tr > td:nth-child(6) > div > a:nth-child(2)');
81  $this->‪openAndCloseTheEditForm($I, $sourceHost . ', ' . $sourcePath);
82  }
83 
89  public function ‪seeStatusCodesWhenCreatingNewRedirect(‪BackendTester $I, Example $example)
90  {
91  $I->amGoingTo('Create a redirect and see the different status codes');
92  $I->click('a[title="Add redirect"]');
93  $I->waitForElementNotVisible('#t3js-ui-block');
94  $I->canSee('Create new Redirect on root level');
95 
96  $I->seeElement('//select[contains(@name, "data[sys_redirect]") and contains(@name, "[target_statuscode]")]//option[@value="' . $example['code'] . '"]');
97  }
98 
103  private function ‪openAndCloseTheEditForm(‪BackendTester $I, string $name): void
104  {
105  $I->waitForElementNotVisible('#t3js-ui-block');
106  $I->canSee('Edit Redirect "' . $name . '" on root level');
107 
108  $I->click('div.module-docheader .btn.t3js-editform-close');
109  $I->waitForElementVisible('table.table-striped');
110  $I->canSee('Redirect Management', 'h1');
111  }
112 
113  protected function ‪possibleRedirectStatusCodes(): array
114  {
115  return [
116  ['code' => 301],
117  ['code' => 302],
118  ['code' => 303],
119  ['code' => 307],
120  ['code' => 308],
121  ];
122  }
123 }
‪TYPO3\CMS\Core\Tests\Acceptance\Backend\Redirect\RedirectModuleCest\openAndCloseTheEditForm
‪openAndCloseTheEditForm(BackendTester $I, string $name)
Definition: RedirectModuleCest.php:103
‪TYPO3\CMS\Core\Tests\Acceptance\Backend\Redirect\RedirectModuleCest\possibleRedirectStatusCodes
‪possibleRedirectStatusCodes()
Definition: RedirectModuleCest.php:113
‪TYPO3\CMS\Core\Tests\Acceptance\Backend\Redirect\RedirectModuleCest\createNewRecordIfNoneExist
‪createNewRecordIfNoneExist(BackendTester $I)
Definition: RedirectModuleCest.php:44
‪TYPO3\CMS\Core\Tests\Acceptance\Backend\Redirect\RedirectModuleCest\_before
‪_before(BackendTester $I)
Definition: RedirectModuleCest.php:32
‪TYPO3\CMS\Core\Tests\Acceptance\Backend\Redirect\RedirectModuleCest\seeStatusCodesWhenCreatingNewRedirect
‪seeStatusCodesWhenCreatingNewRedirect(BackendTester $I, Example $example)
Definition: RedirectModuleCest.php:89
‪TYPO3\CMS\Core\Tests\Acceptance\Backend\Redirect\RedirectModuleCest
Definition: RedirectModuleCest.php:27
‪TYPO3\CMS\Core\Tests\Acceptance\Support\BackendTester
Definition: BackendTester.php:27
‪TYPO3\CMS\Core\Tests\Acceptance\Backend\Redirect
Definition: RedirectModuleCest.php:18
‪TYPO3\CMS\Core\Tests\Acceptance\Backend\Redirect\RedirectModuleCest\canEditRecordFromListView
‪canEditRecordFromListView(BackendTester $I)
Definition: RedirectModuleCest.php:70