diff --git a/behat.dist.yaml b/behat.dist.yaml index 5041adeb..c28bd6bb 100644 --- a/behat.dist.yaml +++ b/behat.dist.yaml @@ -3,6 +3,15 @@ imports: default: extensions: + Behat\MinkExtension: + files_path: "%paths.base%/src/Sylius/Behat/Resources/fixtures/" + base_url: "https://127.0.0.1:8080/" + default_session: symfony + sessions: + symfony: + symfony: ~ + show_auto: false + FriendsOfBehat\SymfonyExtension: bootstrap: tests/bootstrap.php diff --git a/composer.json b/composer.json index f306b89b..4fa53544 100644 --- a/composer.json +++ b/composer.json @@ -44,6 +44,10 @@ "require-dev": { "behat/behat": "^3.16", "doctrine/doctrine-fixtures-bundle": "^3.6", + "friends-of-behat/mink": "^1.11", + "friends-of-behat/mink-browserkit-driver": "^1.6", + "friends-of-behat/mink-extension": "^2.7", + "friends-of-behat/page-object-extension": "^0.3.2", "friends-of-behat/symfony-extension": "^2.6", "matthiasnoback/symfony-config-test": "^5.1", "matthiasnoback/symfony-dependency-injection-test": "^5.1", diff --git a/config/packages/security.yaml b/config/packages/security.yaml index 455e23d8..b595e56d 100644 --- a/config/packages/security.yaml +++ b/config/packages/security.yaml @@ -37,6 +37,7 @@ security: access_control: - { path: ^/admin/login, roles: PUBLIC_ACCESS } - { path: ^/admin/logout, roles: PUBLIC_ACCESS } + - { path: ^/admin/books, roles: PUBLIC_ACCESS } # TODO: to remove, just to simplify for now - { path: ^/admin, roles: ROLE_ADMIN } - { path: ^/, roles: PUBLIC_ACCESS } # - { path: ^/profile, roles: ROLE_USER } diff --git a/config/services_test.yaml b/config/services_test.yaml index 4af151cd..f4cb6c62 100644 --- a/config/services_test.yaml +++ b/config/services_test.yaml @@ -3,6 +3,11 @@ services: autowire: true autoconfigure: true + # TODO should be autoconfigured on friends-of-behat/page-object-extension + _instanceof: + FriendsOfBehat\PageObjectExtension\Page\SymfonyPage: + bind: + $minkParameters: '@behat.mink.parameters' MainTests\Sylius\Behat\: resource: '../tests/Behat/*' diff --git a/tests/Behat/Context/Ui/ManagingBooksContext.php b/tests/Behat/Context/Ui/ManagingBooksContext.php index f9c25149..1e011984 100644 --- a/tests/Behat/Context/Ui/ManagingBooksContext.php +++ b/tests/Behat/Context/Ui/ManagingBooksContext.php @@ -7,16 +7,22 @@ use App\Entity\Book; use Behat\Behat\Context\Context; use Behat\Step\When; +use MainTests\Sylius\Behat\Page\Admin\Book\UpdatePage; use Zenstruck\Foundry\Persistence\Proxy; final class ManagingBooksContext implements Context { + public function __construct( + private readonly UpdatePage $updatePage, + ) { + } + /** * @param Proxy $book */ #[When('/^I want to edit (this book)$/')] public function iWantToEditThisBook(Proxy $book): void { - // For now, we are just testing the shared context transform + $this->updatePage->open(['id' => $book->getId()]); } } diff --git a/tests/Behat/Page/Admin/Book/UpdatePage.php b/tests/Behat/Page/Admin/Book/UpdatePage.php new file mode 100644 index 00000000..5242fc21 --- /dev/null +++ b/tests/Behat/Page/Admin/Book/UpdatePage.php @@ -0,0 +1,25 @@ +getElement('title')->setValue($title); + } + + protected function getDefinedElements(): array + { + return [ + 'title' => '#book_title', + ]; + } +}