diff --git a/.gitignore b/.gitignore index eeb4572c..fdcc2278 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,6 @@ /behat.yml /phpunit.xml /phpspec.yml + +/docker/ +node_modules diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..0e132675 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,15 @@ +version: '3' +services: + db: + image: mariadb:10.6 + environment: + - MYSQL_DATABASE=sylius + - MYSQL_ROOT_PASSWORD=root + - MYSQL_USER=root + - MYSQL_PASSWORD=root + - MYSQL_ROOT_HOST=% + command: --sql_mode="" + ports: + - "3306:3306" + volumes: + - ./docker/volumes/mysql:/var/lib/mysql diff --git a/tests/Application/.env b/tests/Application/.env index 6e0a2f2f..29dc5f19 100644 --- a/tests/Application/.env +++ b/tests/Application/.env @@ -12,7 +12,8 @@ APP_SECRET=EDITME # Format described at http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url # For a sqlite database, use: "sqlite:///%kernel.project_dir%/var/data.db" # Set "serverVersion" to your server version to avoid edge-case exceptions and extra database calls -DATABASE_URL=sqlite:///%kernel.project_dir%/var/db_%kernel.environment%.db +DATABASE_URL="mysql://root:root@127.0.0.1/sylius" + ###< doctrine/doctrine-bundle ### ###> lexik/jwt-authentication-bundle ### diff --git a/tests/Application/public/media/image/.gitignore b/tests/Application/public/media/image/.gitignore deleted file mode 100644 index e69de29b..00000000 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..5425d99d 100644 --- a/tests/Controller/XmlApiTestCase.php +++ b/tests/Controller/XmlApiTestCase.php @@ -11,6 +11,7 @@ use Symfony\Bundle\FrameworkBundle\Console\Application; use Symfony\Component\Console\Tester\CommandTester; use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\HttpKernel\Kernel; abstract class XmlApiTestCase extends BaseXmlApiTestCase { @@ -32,10 +33,20 @@ protected function generateSitemaps(): void $commandTester->execute(['command' => $command->getName()]); } - protected function getBufferedResponse(string $uri): Response + protected function getResponse(string $uri): Response { + if (\version_compare(Kernel::VERSION, '6.0', '>=')) { + $this->doRequest($uri); + + return new Response( + $this->client->getInternalResponse()->getContent(), + $this->client->getInternalResponse()->getStatusCode(), + $this->client->getInternalResponse()->getHeaders(), + ); + } + \ob_start(); - $this->client->request('GET', $uri); + $this->doRequest($uri); $response = $this->client->getResponse(); $contents = \ob_get_clean(); @@ -63,4 +74,9 @@ protected function deleteSitemaps(): void } } } + + private function doRequest(string $uri): void + { + $this->client->request('GET', $uri); + } }