• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

eliashaeussler / typo3-codeception-helper / 19571682840

21 Nov 2025 10:58AM UTC coverage: 77.707% (-3.0%) from 80.69%
19571682840

push

github

web-flow
[TASK] Update armin/editorconfig-cli to v2.2.0

| datasource | package                | from  | to    |
| ---------- | ---------------------- | ----- | ----- |
| packagist  | armin/editorconfig-cli | 2.1.1 | 2.2.0 |

122 of 157 relevant lines covered (77.71%)

2.27 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

97.78
/src/Codeception/Module/Backend.php
1
<?php
2

3
declare(strict_types=1);
4

5
/*
6
 * This file is part of the Composer package "eliashaeussler/typo3-codeception-helper".
7
 *
8
 * Copyright (C) 2023-2025 Elias Häußler <elias@haeussler.dev>
9
 *
10
 * This program is free software: you can redistribute it and/or modify
11
 * it under the terms of the GNU General Public License as published by
12
 * the Free Software Foundation, either version 2 of the License, or
13
 * (at your option) any later version.
14
 *
15
 * This program is distributed in the hope that it will be useful,
16
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
 * GNU General Public License for more details.
19
 *
20
 * You should have received a copy of the GNU General Public License
21
 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22
 */
23

24
namespace EliasHaeussler\Typo3CodeceptionHelper\Codeception\Module;
25

26
use Codeception\Module;
27
use EliasHaeussler\Typo3CodeceptionHelper\Enums;
28
use Facebook\WebDriver;
29

30
use function reset;
31
use function sprintf;
32

33
/**
34
 * Backend.
35
 *
36
 * @author Elias Häußler <elias@haeussler.dev>
37
 * @license GPL-2.0-or-later
38
 *
39
 * @method never fail(string $message = '')
40
 */
41
final class Backend extends Module
42
{
43
    /**
44
     * @var array{userCredentials: array<string, string>}
45
     */
46
    protected array $config = [
47
        'userCredentials' => [
48
            'admin' => 'password',
49
        ],
50
    ];
51

52
    /**
53
     * Perform backend login for the given user. The user is identified
54
     * by the given username and is authenticated by the given password.
55
     *
56
     * Example
57
     * =======
58
     *
59
     * $I->login('admin', 'password');
60
     */
61
    public function login(string $username, string $password): void
2✔
62
    {
63
        $I = $this->getWebDriver();
2✔
64

65
        $I->amOnPage('/typo3/');
2✔
66
        $I->waitForElementVisible(Enums\Selectors::BackendLoginUsernameField);
2✔
67
        $I->waitForElementVisible(Enums\Selectors::BackendLoginPasswordField);
2✔
68
        $I->fillField(Enums\Selectors::BackendLoginUsernameField, $username);
2✔
69
        $I->fillField(Enums\Selectors::BackendLoginPasswordField, $password);
2✔
70
        $I->click(Enums\Selectors::BackendLoginSubmitButton);
2✔
71
        $I->waitForElementNotVisible(Enums\Selectors::BackendLoginForm);
2✔
72
        $I->waitForElementNotVisible(Enums\Selectors::BackendProgressBar);
2✔
73
        $I->seeCookie('be_typo_user');
2✔
74
    }
75

76
    /**
77
     * Perform backend login for the given user. The user is identified
78
     * by the given username which must be configured in the codeception
79
     * module config.
80
     *
81
     * Example
82
     * =======
83
     *
84
     * $I->loginAs('admin');
85
     *
86
     * @param non-empty-string $username
87
     */
88
    public function loginAs(string $username): void
2✔
89
    {
90
        if (!is_string($this->config['userCredentials'][$username] ?? null)) {
2✔
91
            $this->fail(
1✔
92
                sprintf('A user with username "%s" is not configured.', $username),
1✔
93
            );
1✔
94
        }
95

96
        $this->login($username, $this->config['userCredentials'][$username]);
1✔
97
    }
98

99
    /**
100
     * Open a backend module by clicking on the module link. The module
101
     * link is identified by a given node identifier. Note that the
102
     * identifier differs between TYPO3 versions (see example below).
103
     *
104
     * Example
105
     * =======
106
     *
107
     * TYPO3 11
108
     * --------
109
     * $I->openModule('#web_list');
110
     *
111
     * TYPO3 12
112
     * --------
113
     * $I->openModule('[data-modulemenu-identifier="web_list"]');
114
     */
115
    public function openModule(string $identifier): void
1✔
116
    {
117
        $I = $this->getWebDriver();
1✔
118

119
        $I->waitForElementClickable($identifier, 5);
1✔
120
        $I->click($identifier);
1✔
121
        $I->switchToIFrame(Enums\Selectors::BackendContentFrame);
1✔
122
    }
123

124
    public function scrollToElementInModule(string $identifier, int $offsetX = 0, int $offsetY = 0): void
3✔
125
    {
126
        $I = $this->getWebDriver();
3✔
127

128
        /** @var WebDriver\Remote\RemoteWebElement[] $elements */
129
        $elements = $I->_findElements($identifier);
3✔
130
        $element = reset($elements);
3✔
131

132
        if (false === $element) {
3✔
133
            $this->fail(
1✔
134
                sprintf('Element "%s" not found.', $identifier),
1✔
135
            );
1✔
136
        }
137

138
        // Make sure we're in content frame
139
        $I->switchToFrame();
2✔
140
        $I->switchToFrame(Enums\Selectors::BackendContentFrame);
2✔
141

142
        $x = $element->getLocation()->getX() + $offsetX;
2✔
143
        $y = $element->getLocation()->getY() + $offsetY;
2✔
144

145
        $I->executeJS(<<<JS
2✔
146
document.scrollingElement.scrollLeft = {$x};
2✔
147
document.scrollingElement.scrollTop = {$y};
2✔
148
JS
2✔
149
        );
2✔
150

151
        // Wait for scrolling to finish
152
        $I->wait(1);
2✔
153
    }
154

155
    private function getWebDriver(): Module\WebDriver
6✔
156
    {
157
        if (!$this->hasModule('WebDriver')) {
6✔
158
            $this->fail('WebDriver module is not enabled.');
×
159
        }
160

161
        /** @var Module\WebDriver $webDriver */
162
        $webDriver = $this->getModule('WebDriver');
6✔
163

164
        return $webDriver;
6✔
165
    }
166
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc