Skip to content

Draft: Add page resource tests #156

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions features/bootstrap/DoctrineContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -394,13 +394,15 @@ public function theComponentGroupHasTheAllowedComponents(string $allowedComponen
}

/**
* @Given there is a Page
* @Given /^there is a Page(?: with the reference "([^"]+)")*[ and]*(?: with the title "([^"]+)")*(?: with the uiComponent "([^"]+)")*$/
*/
public function thereIsAPage(string $reference = 'page'): Page
public function thereIsAPage(string $reference = 'page', ?string $title = null, ?string $uiComponent = null): Page
{
$page = new Page();
$page->isTemplate = false;
$page->reference = $reference;
$page->setTitle($title);
$page->uiComponent = $uiComponent;
$this->timestampedHelper->persistTimestampedFields($page, true);
$this->manager->persist($page);
$this->manager->flush();
Expand Down
27 changes: 27 additions & 0 deletions features/main/page.feature
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,30 @@ Feature: Page resources
Given there is a Page
When I send a "DELETE" request to the resource "page"
Then the response status code should be 204

@loginAdmin
Scenario: The page resources can be filtered by reference
Given there is a Page with the reference "primary"
And there is a Page with the reference "secondary"
When I send a "GET" request to "/_/pages?reference=primary"
Then the response status code should be 200
And the JSON node "hydra:member" should have "1" elements
And the JSON node "hydra:member[0].reference" should be equal to "primary"

@loginAdmin
Scenario: The page resources can be filtered by title
Given there is a Page with the reference "primary" and with the title "primary"
And there is a Page with the reference "secondary" and with the title "secondary"
When I send a "GET" request to "/_/pages?title=primary"
Then the response status code should be 200
And the JSON node "hydra:member" should have "1" elements
And the JSON node "hydra:member[0].reference" should be equal to "primary"

@loginAdmin
Scenario: The page resources can be filtered by ui component
Given there is a Page with the reference "primary" and with the uiComponent "primary"
And there is a Page with the reference "secondary" and with the uiComponent "secondary"
When I send a "GET" request to "/_/pages?uiComponent=primary"
Then the response status code should be 200
And the JSON node "hydra:member" should have "1" elements
And the JSON node "hydra:member[0].reference" should be equal to "primary"