Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DOCS] Document available module methods #10

Merged
merged 1 commit into from
Sep 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,47 @@ suites:
- EliasHaeussler\Typo3CodeceptionHelper\Codeception\Module\Backend
```

#### Available methods

**`login($username, $password): void`**

Perform backend login for the given user. The user is identified
by the given username and is authenticated by the given password.

Example:

```php
$I->login('admin', 'password');
```

**`loginAs($username): void`**

Perform backend login for the given user. The user is identified
by the given username which must be configured in the codeception
module config (see [Configure backend users](#configure-backend-users)).

Example:

```php
$I->loginAs('admin');
```

**`openModule($identifier): void`**

Open a backend module by clicking on the module link. The module
link is identified by a given node identifier. Note that the
identifier differs between TYPO3 versions (see example below).

Example:

```php
// TYPO3 11
$I->openModule('#web_list');

// TYPO3 12
$I->openModule('[data-modulemenu-identifier="web_list"]');
```

#### Configure backend users

> **Note**
Expand Down
34 changes: 34 additions & 0 deletions src/Codeception/Module/Backend.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@ final class Backend extends Module
],
];

/**
* Perform backend login for the given user. The user is identified
* by the given username and is authenticated by the given password.
*
* Example
* =======
*
* $I->login('admin', 'password');
*/
public function login(string $username, string $password): void
{
/** @var Module\WebDriver $I */
Expand All @@ -61,6 +70,15 @@ public function login(string $username, string $password): void
}

/**
* Perform backend login for the given user. The user is identified
* by the given username which must be configured in the codeception
* module config.
*
* Example
* =======
*
* $I->loginAs('admin');
*
* @param non-empty-string $username
*/
public function loginAs(string $username): void
Expand All @@ -74,6 +92,22 @@ public function loginAs(string $username): void
$this->login($username, $this->config['userCredentials'][$username]);
}

/**
* Open a backend module by clicking on the module link. The module
* link is identified by a given node identifier. Note that the
* identifier differs between TYPO3 versions (see example below).
*
* Example
* =======
*
* TYPO3 11
* --------
* $I->openModule('#web_list');
*
* TYPO3 12
* --------
* $I->openModule('[data-modulemenu-identifier="web_list"]');
*/
public function openModule(string $identifier): void
{
/** @var Module\WebDriver $I */
Expand Down