‪TYPO3CMS  11.5
AbstractCest.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\Scenario;
23 
27 abstract class ‪AbstractCest
28 {
29  protected string ‪$contextMenuMore = 'li.list-group-item-submenu';
30  protected string ‪$contextMenuExport = '[data-callback-action=exportT3d]';
31  protected string ‪$contextMenuImport = '[data-callback-action=importT3d]';
32 
33  protected function ‪selectInContextMenu(‪ApplicationTester $I, array $path): void
34  {
35  foreach ($path as $depth => $selector) {
36  $contextMenuId = sprintf('#contentMenu%d', $depth);
37  $I->waitForElementVisible($contextMenuId, 5);
38  $I->click($selector, $contextMenuId);
39  }
40  }
41 
43  {
44  $I->waitForJS('return $.active == 0;', 10);
45  // sometimes rendering is still slower that ajax being finished.
46  $I->wait(0.5);
47  }
48 
49  protected function ‪setPageAccess(‪ApplicationTester $I, ‪PageTree $pageTree, array $pagePath, int $userGroupId, int $recursionLevel = 1): void
50  {
51  $I->switchToMainFrame();
52  $I->click('Access');
53  $I->waitForElement($this->inPageTree . ' .node', 5);
54  $pageTree->‪openPath($pagePath);
55  $I->switchToContentFrame();
56  $I->wait(2);
57  $I->waitForElementVisible('//table[@id="typo3-permissionList"]/tbody/tr[1]/td[2]/a[@title="Change permissions"]');
58  $I->wait(2);
59  $I->click('//table[@id="typo3-permissionList"]/tbody/tr[1]/td[2]/a[@title="Change permissions"]');
60  $I->wait(2);
61  $I->waitForElementVisible('#PermissionControllerEdit');
62  $I->selectOption('//select[@id="selectGroup"]', ['value' => $userGroupId]);
63  $recursionLevelOption = $I->grabTextFrom('//select[@id="recursionLevel"]/option[' . $recursionLevel . ']');
64  $I->selectOption('//select[@id="recursionLevel"]', ['value' => $recursionLevelOption]);
65  $I->click($this->inModuleHeader . ' .btn[title="Save and close"]');
66  }
67 
68  protected function ‪setModAccess(‪ApplicationTester $I, int $userGroupId, array $modAccessByName): void
69  {
70  try {
71  $I->seeElement($this->inModuleHeader . ' [name=BackendUserModuleMenu]');
72  } catch (\‪Exception $e) {
73  $I->switchToMainFrame();
74  $I->click('Backend Users');
75  $I->switchToContentFrame();
76  }
77 
78  $I->waitForElementVisible($this->inModuleHeader . ' [name=BackendUserModuleMenu]');
79  $I->selectOption($this->inModuleHeader . ' [name=BackendUserModuleMenu]', ['text' => 'Backend user groups']);
80  $I->waitForText('Backend User Group Listing');
81  $I->click('//table/tbody/tr[descendant::a[@data-uid="' . $userGroupId . '"]]/td[2]/a');
82  $I->waitForElementVisible('#EditDocumentController');
83  $I->click('//form[@id="EditDocumentController"]//ul/li[2]/a');
84 
85  foreach ($modAccessByName as $modName => $modAccess) {
86  if ((bool)$modAccess) {
87  $I->checkOption('//input[@value="' . $modName . '"]');
88  } else {
89  $I->uncheckOption('//input[@value="' . $modName . '"]');
90  }
91  }
92 
93  $I->click($this->inModuleHeader . ' .btn[title="Save"]');
94  $I->wait(0.5);
95  $I->click($this->inModuleHeader . ' .btn[title="Close"]');
96  $I->waitForText('Backend User Group Listing');
97  }
98 
99  protected function ‪setUserTsConfig(‪ApplicationTester $I, Scenario $scenario, int $userId, string $userTsConfig): void
100  {
101  try {
102  $I->seeElement($this->inModuleHeader . ' [name=BackendUserModuleMenu]');
103  } catch (\‪Exception $e) {
104  $I->switchToMainFrame();
105  $I->click('Backend Users');
106  $I->switchToContentFrame();
107  }
108 
109  $I->waitForElementVisible($this->inModuleHeader . ' [name=BackendUserModuleMenu]');
110  $I->selectOption($this->inModuleHeader . ' [name=BackendUserModuleMenu]', ['text' => 'Backend users']);
111  $I->waitForElement('#typo3-backend-user-list');
112  $I->click('//table[@id="typo3-backend-user-list"]/tbody/tr[descendant::a[@data-uid="' . $userId . '"]]//a[@title="Edit"]');
113  $I->waitForElement('#EditDocumentController');
114  $I->click('//form[@id="EditDocumentController"]//ul/li[4]/a');
115  $isComposerMode = str_contains($scenario->current('env'), 'composer');
116  if ($isComposerMode) {
117  $codeMirrorSelector = 'typo3-t3editor-codemirror[name="data[be_users][' . $userId . '][TSconfig]"]';
118  $I->waitForElementVisible($codeMirrorSelector);
119  $I->executeJS("document.querySelector('" . $codeMirrorSelector . "').setContent('" . implode('\n', explode("\n", $userTsConfig)) . "')");
120  } else {
121  $I->fillField('//div[@class="tab-content"]/div[4]/fieldset[1]//textarea', $userTsConfig);
122  }
123  $I->click($this->inModuleHeader . ' .btn[title="Save"]');
124  $I->wait(0.5);
125  $I->click($this->inModuleHeader . ' .btn[title="Close"]');
126  $I->waitForElement('#typo3-backend-user-list');
127  }
128 }
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Impexp\AbstractCest\$contextMenuMore
‪string $contextMenuMore
Definition: AbstractCest.php:29
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Impexp\AbstractCest\setModAccess
‪setModAccess(ApplicationTester $I, int $userGroupId, array $modAccessByName)
Definition: AbstractCest.php:68
‪TYPO3\CMS\Core\Exception
Definition: Exception.php:21
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Impexp\AbstractCest\$contextMenuImport
‪string $contextMenuImport
Definition: AbstractCest.php:31
‪TYPO3\CMS\Core\Tests\Acceptance\Support\ApplicationTester
Definition: ApplicationTester.php:27
‪TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\PageTree\openPath
‪openPath(array $path)
Definition: PageTree.php:76
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Impexp\AbstractCest\setUserTsConfig
‪setUserTsConfig(ApplicationTester $I, Scenario $scenario, int $userId, string $userTsConfig)
Definition: AbstractCest.php:99
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Impexp\AbstractCest\setPageAccess
‪setPageAccess(ApplicationTester $I, PageTree $pageTree, array $pagePath, int $userGroupId, int $recursionLevel=1)
Definition: AbstractCest.php:49
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Impexp\AbstractCest\waitForAjaxRequestToFinish
‪waitForAjaxRequestToFinish(ApplicationTester $I)
Definition: AbstractCest.php:42
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Impexp
Definition: AbstractCest.php:18
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Impexp\AbstractCest
Definition: AbstractCest.php:28
‪TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\PageTree
Definition: PageTree.php:31
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Impexp\AbstractCest\selectInContextMenu
‪selectInContextMenu(ApplicationTester $I, array $path)
Definition: AbstractCest.php:33
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Impexp\AbstractCest\$contextMenuExport
‪string $contextMenuExport
Definition: AbstractCest.php:30