‪TYPO3CMS  ‪main
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\Attribute\DataProvider;
21 use Codeception\Example;
23 
28 {
29  public function ‪_before(‪ApplicationTester $I): void
30  {
31  $I->useExistingSession('admin');
32  $I->click('Redirects');
33  $I->switchToContentFrame();
34  $I->canSee('Redirect Management', 'h1');
35  }
36 
38  {
39  $I->amGoingTo('create a new redirects record while none are in the system, yet');
40  $I->canSee('No redirects found!');
41  $I->click('Create new redirect');
42  $I->waitForElementNotVisible('#t3js-ui-block');
43  $I->canSee('Create new Redirect on root level');
44 
45  $I->fillField('//input[contains(@data-formengine-input-name, "data[sys_redirect]") and contains(@data-formengine-input-name, "[source_path]")]', '/my-path/');
46  $I->fillField('//input[contains(@data-formengine-input-name, "data[sys_redirect]") and contains(@data-formengine-input-name, "[target]")]', 1);
47 
48  $saveButtonLink = '//*/button[@name="_savedok"][1]';
49  $I->waitForElement($saveButtonLink, 30);
50  $I->click($saveButtonLink);
51  $I->waitForElementNotVisible('#t3js-ui-block');
52 
53  $I->click('div.module-docheader .btn.t3js-editform-close');
54 
55  $I->waitForElementVisible('table.table-striped');
56  $I->canSee('Redirect Management', 'h1');
57  $I->canSeeNumberOfElements('table.table-striped > tbody > tr', 1);
58  }
59 
61  {
62  $sourceHost = $I->grabTextFrom('table.table-striped > tbody > tr > td:nth-child(3)');
63  $sourcePath = $I->grabTextFrom('table.table-striped > tbody > tr > td:nth-child(4) > a');
64 
65  $I->amGoingTo('test edit on source path');
66  $I->click('table.table-striped > tbody > tr > td:nth-child(4) > a');
67  $I->waitForElementNotVisible('#t3js-ui-block');
68  $I->canSee('Edit Redirect "' . $sourceHost . ', ' . $sourcePath . '" on root level');
69  $I->click('div.module-docheader .btn.t3js-editform-close');
70  $I->waitForElementVisible('table.table-striped');
71  $I->canSee('Redirect Management', 'h1');
72 
73  $I->amGoingTo('test edit on edit button');
74  $I->click('table.table-striped > tbody > tr > td.col-control > div > a:nth-child(2)');
75  $I->waitForElementNotVisible('#t3js-ui-block');
76  $I->canSee('Edit Redirect "' . $sourceHost . ', ' . $sourcePath . '" on root level');
77  $I->click('div.module-docheader .btn.t3js-editform-close');
78  $I->waitForElementVisible('table.table-striped');
79  $I->canSee('Redirect Management', 'h1');
80  }
81 
82  protected function ‪possibleRedirectStatusCodes(): array
83  {
84  return [
85  ['code' => 301],
86  ['code' => 302],
87  ['code' => 303],
88  ['code' => 307],
89  ['code' => 308],
90  ];
91  }
92 
93  #[DataProvider('possibleRedirectStatusCodes')]
94  public function ‪seeStatusCodesWhenCreatingNewRedirect(‪ApplicationTester $I, Example $example): void
95  {
96  $I->amGoingTo('Create a redirect and see the different status codes');
97  $I->click('a[title="Add redirect"]');
98  $I->waitForElementNotVisible('#t3js-ui-block');
99  $I->canSee('Create new Redirect on root level');
100  $I->seeElement('//select[contains(@name, "data[sys_redirect]") and contains(@name, "[target_statuscode]")]//option[@value="' . $example['code'] . '"]');
101  }
102 }
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Redirect\RedirectModuleCest\canEditRecordFromListView
‪canEditRecordFromListView(ApplicationTester $I)
Definition: RedirectModuleCest.php:60
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Redirect
Definition: RedirectModuleCest.php:18
‪TYPO3\CMS\Core\Tests\Acceptance\Support\ApplicationTester
Definition: ApplicationTester.php:28
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Redirect\RedirectModuleCest\createNewRecordIfNoneExist
‪createNewRecordIfNoneExist(ApplicationTester $I)
Definition: RedirectModuleCest.php:37
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Redirect\RedirectModuleCest
Definition: RedirectModuleCest.php:28
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Redirect\RedirectModuleCest\possibleRedirectStatusCodes
‪possibleRedirectStatusCodes()
Definition: RedirectModuleCest.php:82
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Redirect\RedirectModuleCest\_before
‪_before(ApplicationTester $I)
Definition: RedirectModuleCest.php:29
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Redirect\RedirectModuleCest\seeStatusCodesWhenCreatingNewRedirect
‪seeStatusCodesWhenCreatingNewRedirect(ApplicationTester $I, Example $example)
Definition: RedirectModuleCest.php:94