From 26dd39b163d88207acd3e2f54b7d35e6780f7671 Mon Sep 17 00:00:00 2001 From: Stefan Doorn Date: Wed, 18 Dec 2024 12:00:07 +0100 Subject: [PATCH] Do not use buffered responses --- .../MultiChannelSitemapIndexControllerApiTest.php | 4 ++-- .../MultiChannelSitemapStaticControllerApiTest.php | 2 +- tests/Controller/SitemapIndexControllerApiTest.php | 6 +++--- tests/Controller/SitemapProductControllerApiImagesTest.php | 2 +- .../SitemapProductControllerApiLocalesImagesTest.php | 2 +- .../Controller/SitemapProductControllerApiLocalesTest.php | 2 +- tests/Controller/SitemapProductControllerApiTest.php | 2 +- .../SitemapProductControllerApiUniqueLocaleChannelTest.php | 2 +- tests/Controller/SitemapStaticControllerApiTest.php | 2 +- tests/Controller/SitemapTaxonControllerApiLocalesTest.php | 2 +- tests/Controller/SitemapTaxonControllerApiTest.php | 2 +- tests/Controller/XmlApiTestCase.php | 7 ++----- 12 files changed, 16 insertions(+), 19 deletions(-) diff --git a/tests/Controller/MultiChannelSitemapIndexControllerApiTest.php b/tests/Controller/MultiChannelSitemapIndexControllerApiTest.php index d784d301..4fd0a0fc 100644 --- a/tests/Controller/MultiChannelSitemapIndexControllerApiTest.php +++ b/tests/Controller/MultiChannelSitemapIndexControllerApiTest.php @@ -11,10 +11,10 @@ public function testShowActionResponse() $this->loadFixturesFromFiles(['multi_channel.yaml']); $this->generateSitemaps(); - $response = $this->getBufferedResponse('http://localhost/sitemap_index.xml'); + $response = $this->getResponse('http://localhost/sitemap_index.xml'); $this->assertResponse($response, 'show_sitemap_index'); - $response = $this->getBufferedResponse('http://store.fr/sitemap_index.xml'); + $response = $this->getResponse('http://store.fr/sitemap_index.xml'); $this->assertResponse($response, 'show_second_sitemap_index'); $this->deleteSitemaps(); diff --git a/tests/Controller/MultiChannelSitemapStaticControllerApiTest.php b/tests/Controller/MultiChannelSitemapStaticControllerApiTest.php index b77997c3..5679a399 100644 --- a/tests/Controller/MultiChannelSitemapStaticControllerApiTest.php +++ b/tests/Controller/MultiChannelSitemapStaticControllerApiTest.php @@ -11,7 +11,7 @@ public function testShowActionResponse() $this->loadFixturesFromFiles(['multi_channel.yaml']); $this->generateSitemaps(); - $response = $this->getBufferedResponse('http://store.fr/sitemap/static.xml'); + $response = $this->getResponse('http://store.fr/sitemap/static.xml'); $this->assertResponse($response, 'show_sitemap_static_fr'); } diff --git a/tests/Controller/SitemapIndexControllerApiTest.php b/tests/Controller/SitemapIndexControllerApiTest.php index 4981fef4..9f8b4a54 100644 --- a/tests/Controller/SitemapIndexControllerApiTest.php +++ b/tests/Controller/SitemapIndexControllerApiTest.php @@ -14,21 +14,21 @@ protected function setUp(): void public function testRedirectActionResponse() { - $response = $this->getBufferedResponse('/sitemap.xml'); + $response = $this->getResponse('/sitemap.xml'); self::assertResponseRedirects('http://localhost/sitemap_index.xml', 301); $this->deleteSitemaps(); } public function testShowActionResponse() { - $response = $this->getBufferedResponse('/sitemap_index.xml'); + $response = $this->getResponse('/sitemap_index.xml'); $this->assertResponse($response, 'show_sitemap_index'); $this->deleteSitemaps(); } public function testRedirectResponse() { - $response = $this->getBufferedResponse('/sitemap.xml'); + $response = $this->getResponse('/sitemap.xml'); $this->assertResponseCode($response, 301); $this->assertTrue($response->isRedirect()); diff --git a/tests/Controller/SitemapProductControllerApiImagesTest.php b/tests/Controller/SitemapProductControllerApiImagesTest.php index 6707891b..d0d17a33 100644 --- a/tests/Controller/SitemapProductControllerApiImagesTest.php +++ b/tests/Controller/SitemapProductControllerApiImagesTest.php @@ -10,7 +10,7 @@ public function testShowActionResponse() { $this->loadFixturesFromFiles(['channel.yaml', 'product_images.yaml']); $this->generateSitemaps(); - $response = $this->getBufferedResponse('/sitemap/products.xml'); + $response = $this->getResponse('/sitemap/products.xml'); $this->assertResponse($response, 'show_sitemap_products_image'); $this->deleteSitemaps(); diff --git a/tests/Controller/SitemapProductControllerApiLocalesImagesTest.php b/tests/Controller/SitemapProductControllerApiLocalesImagesTest.php index 2b0b3f8b..ca4ac5b4 100644 --- a/tests/Controller/SitemapProductControllerApiLocalesImagesTest.php +++ b/tests/Controller/SitemapProductControllerApiLocalesImagesTest.php @@ -10,7 +10,7 @@ public function testShowActionResponse() { $this->loadFixturesFromFiles(['channel.yaml', 'product_locale_image.yaml']); $this->generateSitemaps(); - $response = $this->getBufferedResponse('/sitemap/products.xml'); + $response = $this->getResponse('/sitemap/products.xml'); $this->assertResponse($response, 'show_sitemap_products_locale_image'); $this->deleteSitemaps(); diff --git a/tests/Controller/SitemapProductControllerApiLocalesTest.php b/tests/Controller/SitemapProductControllerApiLocalesTest.php index 5d07bfa1..267c2a6b 100644 --- a/tests/Controller/SitemapProductControllerApiLocalesTest.php +++ b/tests/Controller/SitemapProductControllerApiLocalesTest.php @@ -10,7 +10,7 @@ public function testShowActionResponse() { $this->loadFixturesFromFiles(['channel.yaml', 'product_locale.yaml']); $this->generateSitemaps(); - $response = $this->getBufferedResponse('/sitemap/products.xml'); + $response = $this->getResponse('/sitemap/products.xml'); $this->assertResponse($response, 'show_sitemap_products_locale'); $this->deleteSitemaps(); } diff --git a/tests/Controller/SitemapProductControllerApiTest.php b/tests/Controller/SitemapProductControllerApiTest.php index 99e19821..ff8bef19 100644 --- a/tests/Controller/SitemapProductControllerApiTest.php +++ b/tests/Controller/SitemapProductControllerApiTest.php @@ -11,7 +11,7 @@ public function testShowActionResponse() $this->loadFixturesFromFiles(['channel.yaml', 'product.yaml']); $this->generateSitemaps(); - $response = $this->getBufferedResponse('/sitemap/products.xml'); + $response = $this->getResponse('/sitemap/products.xml'); $this->assertResponse($response, 'show_sitemap_products'); $this->deleteSitemaps(); } diff --git a/tests/Controller/SitemapProductControllerApiUniqueLocaleChannelTest.php b/tests/Controller/SitemapProductControllerApiUniqueLocaleChannelTest.php index 95f4ba9f..09c5ec35 100644 --- a/tests/Controller/SitemapProductControllerApiUniqueLocaleChannelTest.php +++ b/tests/Controller/SitemapProductControllerApiUniqueLocaleChannelTest.php @@ -11,7 +11,7 @@ public function testShowActionResponse() $this->loadFixturesFromFiles(['product_unique_locale_channel.yaml']); $this->generateSitemaps(); - $response = $this->getBufferedResponse('/sitemap/products.xml'); + $response = $this->getResponse('/sitemap/products.xml'); $this->assertResponse($response, 'show_sitemap_products_unique_channel_locale'); $this->deleteSitemaps(); diff --git a/tests/Controller/SitemapStaticControllerApiTest.php b/tests/Controller/SitemapStaticControllerApiTest.php index febb42c6..f463a19e 100644 --- a/tests/Controller/SitemapStaticControllerApiTest.php +++ b/tests/Controller/SitemapStaticControllerApiTest.php @@ -10,7 +10,7 @@ public function testShowActionResponse() { $this->loadFixturesFromFiles(['channel.yaml']); $this->generateSitemaps(); - $response = $this->getBufferedResponse('/sitemap/static.xml'); + $response = $this->getResponse('/sitemap/static.xml'); $this->assertResponse($response, 'show_sitemap_static'); $this->deleteSitemaps(); diff --git a/tests/Controller/SitemapTaxonControllerApiLocalesTest.php b/tests/Controller/SitemapTaxonControllerApiLocalesTest.php index 46c98615..9e52035f 100644 --- a/tests/Controller/SitemapTaxonControllerApiLocalesTest.php +++ b/tests/Controller/SitemapTaxonControllerApiLocalesTest.php @@ -10,7 +10,7 @@ public function testShowActionResponse() { $this->loadFixturesFromFiles(['channel.yaml', 'taxon_locale.yaml']); $this->generateSitemaps(); - $response = $this->getBufferedResponse('/sitemap/taxons.xml'); + $response = $this->getResponse('/sitemap/taxons.xml'); $this->assertResponse($response, 'show_sitemap_taxons_locale'); $this->deleteSitemaps(); diff --git a/tests/Controller/SitemapTaxonControllerApiTest.php b/tests/Controller/SitemapTaxonControllerApiTest.php index 132ab084..02a98931 100644 --- a/tests/Controller/SitemapTaxonControllerApiTest.php +++ b/tests/Controller/SitemapTaxonControllerApiTest.php @@ -10,7 +10,7 @@ public function testShowActionResponse() { $this->loadFixturesFromFiles(['channel.yaml', 'taxon.yaml']); $this->generateSitemaps(); - $response = $this->getBufferedResponse('/sitemap/taxons.xml'); + $response = $this->getResponse('/sitemap/taxons.xml'); $this->assertResponse($response, 'show_sitemap_taxons'); $this->deleteSitemaps(); diff --git a/tests/Controller/XmlApiTestCase.php b/tests/Controller/XmlApiTestCase.php index 50e0ea9f..0925b71a 100644 --- a/tests/Controller/XmlApiTestCase.php +++ b/tests/Controller/XmlApiTestCase.php @@ -32,14 +32,11 @@ protected function generateSitemaps(): void $commandTester->execute(['command' => $command->getName()]); } - protected function getBufferedResponse(string $uri): Response + protected function getResponse(string $uri): Response { - \ob_start(); $this->client->request('GET', $uri); - $response = $this->client->getResponse(); - $contents = \ob_get_clean(); - return new Response($contents, $response->getStatusCode(), $response->headers->all()); + return $this->client->getResponse(); } protected function deleteSitemaps(): void