Skip to content

Commit

Permalink
Update page
Browse files Browse the repository at this point in the history
  • Loading branch information
loic425 committed Dec 10, 2024
1 parent 617d1e9 commit 07703fe
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 1 deletion.
9 changes: 9 additions & 0 deletions behat.dist.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

4 changes: 4 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions config/packages/security.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
5 changes: 5 additions & 0 deletions config/services_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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/*'
8 changes: 7 additions & 1 deletion tests/Behat/Context/Ui/ManagingBooksContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -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> $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()]);
}
}
25 changes: 25 additions & 0 deletions tests/Behat/Page/Admin/Book/UpdatePage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

namespace MainTests\Sylius\Behat\Page\Admin\Book;

use FriendsOfBehat\PageObjectExtension\Page\SymfonyPage;

final class UpdatePage extends SymfonyPage
{
public function getRouteName(): string
{
return 'app_admin_book_update';
}

public function changeTitle(string $title): void
{
$this->getElement('title')->setValue($title);
}

protected function getDefinedElements(): array
{
return [
'title' => '#book_title',
];
}
}

0 comments on commit 07703fe

Please sign in to comment.