-
Notifications
You must be signed in to change notification settings - Fork 83
Expand file tree
/
Copy pathBackendTester.php
More file actions
147 lines (130 loc) · 5.02 KB
/
BackendTester.php
File metadata and controls
147 lines (130 loc) · 5.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
<?php
declare(strict_types=1);
namespace B13\Container\Tests\Acceptance\Support;
/*
* This file is part of TYPO3 CMS-based extension "container" by b13.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*/
use B13\Container\Tests\Acceptance\Support\_generated\BackendTesterActions;
use Codeception\Util\Locator;
use TYPO3\CMS\Core\Information\Typo3Version;
use TYPO3\TestingFramework\Core\Acceptance\Step\FrameSteps;
class BackendTester extends \Codeception\Actor
{
use BackendTesterActions;
use FrameSteps;
public function getTypo3MajorVersion(): int
{
return (new Typo3Version())->getMajorVersion();
}
public function loginAs(string $username): void
{
$I = $this;
if ($I->loadSessionSnapshot($username . 'Login')) {
$I->amOnPage('/typo3');
} else {
$I->amOnPage('/typo3');
$I->waitForElement('body[data-typo3-login-ready]');
// logging in
$I->amOnPage('/typo3');
$I->submitForm('#typo3-login-form', [
'username' => $username,
'p_field' => 'password',
]);
$I->saveSessionSnapshot($username . 'Login');
}
$I->waitForElement('iframe[name="list_frame"]');
$I->switchToIFrame('list_frame');
$I->waitForElement(Locator::firstElement('div.module'));
$I->switchToIFrame();
}
/**
* v14: Click a content element in the page module to open it in the context panel,
* then switch into the context panel iframe.
*/
public function openRecordInContextPanelOrWithEditDocumentController(int $uid): void
{
if ($this->getTypo3MajorVersion() < 14 || (new Typo3Version())->getBranch() === '14.1') {
$this->waitForElement('#element-tt_content-' . $uid . ' a[title="Edit"]');
$this->click('#element-tt_content-' . $uid . ' a[title="Edit"]');
} else {
$this->waitForElement('#element-tt_content-' . $uid . ' typo3-backend-contextual-record-edit-trigger');
$this->click('#element-tt_content-' . $uid . ' typo3-backend-contextual-record-edit-trigger');
$this->switchToMainFrame();
$this->waitForElement('iframe[name="modal_frame"]', 10);
$this->switchToIFrame('modal_frame');
$this->waitForElementNotVisible('#t3js-ui-block');
$this->click('a.t3js-contextual-fullscreen');
$this->switchToMainFrame();
$this->switchToContentFrame();
}
$this->waitForElement('#EditDocumentController');
}
public function getDataColPos(int $containerId, int $colPos): string
{
return (string)$colPos;
}
public function clickLayoutModuleButton(): void
{
if ($this->getTypo3MajorVersion() < 14) {
$this->click('Page');
} else {
$this->click('Layout');
}
}
public function clickNewContentElement(string $colPosSelector): void
{
$this->waitForElement($colPosSelector);
$this->click($colPosSelector . ' typo3-backend-new-content-element-wizard-button');
}
public function getNewContentElementLabel(): string
{
return 'Create new content';
}
public function getNewRecordWizardSelector(): string
{
return 'typo3-backend-new-record-wizard';
}
public function waitForModal(): void
{
if ($this->getTypo3MajorVersion() < 14) {
$this->waitForElement('.modal-dialog');
} else {
$this->waitForElement('dialog.t3js-modal');
}
}
public function selectGermanInLanguageMenu(): void
{
if ($this->getTypo3MajorVersion() < 14) {
$this->waitForText('Language');
$this->click('Language');
$this->waitForText('german');
$this->click('german');
} else {
$this->waitForText('english');
//$this->click('english');
if ((new Typo3Version())->getBranch() === '14.1') {
$this->click('.module-docheader-bar-column button');
} else {
$this->click('.module-docheader-column button.dropdown-toggle');
}
$this->waitForText('german');
$this->click('german');
}
}
public function selectLanguageComparisonMode(): void
{
if ($this->getTypo3MajorVersion() < 14) {
$this->waitForElement('select[name="actionMenu"]');
$this->selectOption('select[name="actionMenu"]', 'Language Comparison');
} else {
$this->waitForElementVisible('.module-docheader-buttons .btn-group button.dropdown-toggle');
$this->click('.module-docheader-buttons .btn-group button.dropdown-toggle');
$this->waitForElementVisible('.module-docheader-buttons .dropdown-menu');
$this->click('Language Comparison', '.module-docheader-buttons .dropdown-menu');
}
}
}