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

eliashaeussler / typo3-codeception-helper / 8935379460

03 May 2024 07:07AM CUT coverage: 77.686%. Remained the same
8935379460

push

github

web-flow
[TASK] Update eliashaeussler/php-cs-fixer-config to v2.1.1

| datasource | package                            | from  | to    |
| ---------- | ---------------------------------- | ----- | ----- |
| packagist  | eliashaeussler/php-cs-fixer-config | 2.1.0 | 2.1.1 |

94 of 121 relevant lines covered (77.69%)

2.18 hits per line

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

100.0
/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-2024 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

29
use function sprintf;
30

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

48
    /**
49
     * Perform backend login for the given user. The user is identified
50
     * by the given username and is authenticated by the given password.
51
     *
52
     * Example
53
     * =======
54
     *
55
     * $I->login('admin', 'password');
56
     */
57
    public function login(string $username, string $password): void
2✔
58
    {
59
        /** @var Module\WebDriver $I */
60
        $I = $this->getModule('WebDriver');
2✔
61

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

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

92
        $this->login($username, $this->config['userCredentials'][$username]);
1✔
93
    }
94

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

116
        $I->waitForElementClickable($identifier, 5);
1✔
117
        $I->click($identifier);
1✔
118
        $I->switchToIFrame(Enums\Selectors::BackendContentFrame->value);
1✔
119
    }
120
}
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

© 2025 Coveralls, Inc