Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
7 / 7 |
|
100.00% |
4 / 4 |
CRAP | |
100.00% |
1 / 1 |
| HomepageContext | |
100.00% |
7 / 7 |
|
100.00% |
4 / 4 |
5 | |
100.00% |
1 / 1 |
| theResponseCodeShouldBe | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| iShouldSeeTheDefaultWelcomeMessage | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| iShouldSeeTheWelcomeMessageForAuthenticatedUser | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| iShouldSeeMyLoansLink | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | // ╔════════════════════════════════════════════════════════════╗ |
| 4 | // ║ MIT Licence (#Expat) - https://opensource.org/licenses/MIT ║ |
| 5 | // ║ Copyright 2026 Frederic Poeydomenge <dyno@phexium.com> ║ |
| 6 | // ╚════════════════════════════════════════════════════════════╝ |
| 7 | |
| 8 | declare(strict_types=1); |
| 9 | |
| 10 | namespace Tests\AppDemo\Acceptance; |
| 11 | |
| 12 | use Assert\Assert; |
| 13 | use Behat\Step\Then; |
| 14 | use Nyholm\Psr7\Response; |
| 15 | use Tests\AppDemo\Acceptance\Trait\BrowsePageTrait; |
| 16 | |
| 17 | final class HomepageContext extends BehatContext |
| 18 | { |
| 19 | use BrowsePageTrait; |
| 20 | |
| 21 | private Response $response; |
| 22 | |
| 23 | #[Then('the response code should be :statusCode')] |
| 24 | public function theResponseCodeShouldBe(int $statusCode): void |
| 25 | { |
| 26 | Assert::that($this->response->getStatusCode())->same($statusCode); |
| 27 | } |
| 28 | |
| 29 | #[Then('I should see the default welcome message')] |
| 30 | public function iShouldSeeTheDefaultWelcomeMessage(): void |
| 31 | { |
| 32 | Assert::that((string) $this->response->getBody())->contains('Welcome to CleanShelf'); |
| 33 | } |
| 34 | |
| 35 | #[Then('/I should see the welcome message for (.*)/')] |
| 36 | public function iShouldSeeTheWelcomeMessageForAuthenticatedUser(string $email): void |
| 37 | { |
| 38 | Assert::that((string) $this->response->getBody())->contains('Welcome, '.$email); |
| 39 | } |
| 40 | |
| 41 | #[Then('/I should (not )?see MyLoans link/')] |
| 42 | public function iShouldSeeMyLoansLink(bool $not = false): void |
| 43 | { |
| 44 | $body = (string) $this->response->getBody(); |
| 45 | |
| 46 | if ($not === false) { |
| 47 | Assert::that($body)->contains('My Loans'); |
| 48 | } else { |
| 49 | Assert::that($body)->notContains('My Loans'); |
| 50 | } |
| 51 | } |
| 52 | } |