Skip to content

Commit

Permalink
Use different content fetching for SF6 and earlier
Browse files Browse the repository at this point in the history
  • Loading branch information
stefandoorn committed Dec 18, 2024
1 parent 5b6a860 commit 0750ff4
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 6 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@
/behat.yml
/phpunit.xml
/phpspec.yml

/docker/
node_modules
15 changes: 15 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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
27 changes: 21 additions & 6 deletions tests/Controller/XmlApiTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -34,13 +35,22 @@ protected function generateSitemaps(): void

protected function getResponse(string $uri): Response
{
$this->client->request('GET', $uri);
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->doRequest($uri);
$response = $this->client->getResponse();
$contents = \ob_get_clean();

return new Response(
$this->client->getInternalResponse()->getContent(),
$this->client->getInternalResponse()->getStatusCode(),
$this->client->getInternalResponse()->getHeaders(),
);
return new Response($contents, $response->getStatusCode(), $response->headers->all());
}

protected function deleteSitemaps(): void
Expand All @@ -64,4 +74,9 @@ protected function deleteSitemaps(): void
}
}
}

private function doRequest(string $uri): void
{
$this->client->request('GET', $uri);
}
}

0 comments on commit 0750ff4

Please sign in to comment.