From ae40a00b5a2b66e7599524dbcc085b111a17c8b3 Mon Sep 17 00:00:00 2001 From: bfalke Date: Thu, 27 Oct 2022 19:35:49 +0200 Subject: [PATCH] Add tests for filtering pages by refernce, title and uiComponent --- features/bootstrap/DoctrineContext.php | 6 ++++-- features/main/page.feature | 27 ++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/features/bootstrap/DoctrineContext.php b/features/bootstrap/DoctrineContext.php index 1a5e145d..9bd993e9 100644 --- a/features/bootstrap/DoctrineContext.php +++ b/features/bootstrap/DoctrineContext.php @@ -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(); diff --git a/features/main/page.feature b/features/main/page.feature index 5d55f436..e261af8f 100644 --- a/features/main/page.feature +++ b/features/main/page.feature @@ -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"