Skip to content

Commit

Permalink
Merge pull request #10 from eliashaeussler/docs/modules
Browse files Browse the repository at this point in the history
[DOCS] Document available module methods
  • Loading branch information
eliashaeussler authored Sep 6, 2023
2 parents 10595e0 + 29b0a77 commit 6f3f962
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 0 deletions.
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

0 comments on commit 6f3f962

Please sign in to comment.