<?php declare(strict_types=1); namespace App\Tests\Behat; use Behat\MinkExtension\Context\MinkContext; final class ZamaContext extends MinkContext { /** * @Then /^I should see a platform$/ */ public function iShouldSeeAPlatform(): void { $time = 5000; // time should be in milliseconds $this->getSession()->wait($time, '(0 === jQuery.active)'); $this->assertPageContainsText('Test Platform'); } }
Installation Behat
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean vestibulum iaculis hendrerit. Donec aliquam ultricies lacus a dapibus. Integer bibendum ante non erat venenatis, at consectetur tortor facilisis. Sed sodales blandit sapien, vestibulum porta mauris suscipit venenatis. Fusce congue mi vel interdum pulvinar. Pellentesque a neque elit. Donec faucibus erat pulvinar gravida tempus.
Exemple de scénario
Feature: UsersIn order to prove that the API is secureNot logged as a userI want to try to call a route of the API
Scenario: It receives a 401 error from the API if not connectedWhen I request "GET /api/fr/app/admin/degree/list"Then I get a "401" response
Scenario: It receives a 401 response code if trying to connect to the API with the wrong passwordGiven I have the payload:"""{"username":"toto","password":"totu"}"""When I request "POST /api/login_check"Then I get a "401" response
Scenario: It receives a 200 response code and a token if trying to connect to the API with the good passwordGiven I have the payload:"""{"username":"admin","password":"Pass$Admin"}"""When I request "POST /api/login_check"Then I get a "200" responseAnd the "token" property exists