From 4016435d364b4330bc6b03e4d9619005e2d7bad2 Mon Sep 17 00:00:00 2001
From: Stefan Doorn <stefan@efectos.nl>
Date: Wed, 18 Dec 2024 13:52:17 +0100
Subject: [PATCH] Support Sylius 2.0

---
 .github/workflows/build.yml                   |  8 ++---
 composer.json                                 | 35 +++++++++----------
 tests/Application/config/bundles.php          |  9 ++---
 .../Application/config/packages/fos_rest.yaml | 11 ------
 tests/Controller/XmlApiTestCase.php           | 26 ++++----------
 5 files changed, 30 insertions(+), 59 deletions(-)
 delete mode 100644 tests/Application/config/packages/fos_rest.yaml

diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 6da94f87..907500aa 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -21,12 +21,12 @@ jobs:
         strategy:
             fail-fast: false
             matrix:
-                php: ["8.1", "8.2", "8.3"]
-                symfony: ["^5.4", "^6.4"]
-                sylius: ["~1.13.0", "~1.14.0"]
+                php: ["8.2", "8.3"]
+                symfony: ["^6.4"]
+                sylius: ["~2.0.0"]
                 node: ["14.x"]
                 mysql: ["8.0"]
-
+                      
         env:
             APP_ENV: test
             DATABASE_URL: "mysql://root:root@127.0.0.1/sylius?serverVersion=${{ matrix.mysql }}"
diff --git a/composer.json b/composer.json
index 9ccc17e2..b0f83b63 100644
--- a/composer.json
+++ b/composer.json
@@ -7,17 +7,14 @@
         "sylius-plugin"
     ],
     "license": "MIT",
-    "conflict": {
-        "twig/twig": "<2.9"
-    },
     "require": {
-        "php": "^7.4 || ^8.1",
-        "sylius/sylius": "~1.9.0 || ~1.10.0 || ~1.11.0 || ~1.12.0 || ~1.13.0 || ~1.14.0"
+        "php": "^8.2",
+        "sylius/sylius": "~2.0.0"
     },
     "require-dev": {
-        "api-platform/core": "~2.5.0 || ~2.6.0 || ~2.7.0",
+        "api-platform/core": "^2.7.0",
         "lchrusciel/api-test-case": "^5.1",
-        "league/flysystem-bundle": "^2.0 || ^3.0",
+        "league/flysystem-bundle": "^3.0",
         "matthiasnoback/symfony-dependency-injection-test": "^4.3",
         "phpspec/phpspec": "^7.0",
         "phpstan/extension-installer": "^1.0",
@@ -29,15 +26,16 @@
         "phpunit/phpunit": "^9.5",
         "sylius-labs/coding-standard": "^4.0",
         "sylius/calendar": "^0.5.0",
-        "sylius/state-machine-abstraction": "^1.0",
-        "symfony/browser-kit": "^4.4 || ^5.4 || ^6.4",
-        "symfony/debug-bundle": "^4.4 || ^5.4 || ^6.4",
-        "symfony/dotenv": "^4.4 || ^5.4 || ^6.4",
-        "symfony/intl": "^4.4 || ^5.4 || ^6.4",
-        "symfony/runtime": "^4.4 || ^5.4 || ^6.4 || ^7.0",
-        "symfony/web-profiler-bundle": "^4.4 || ^5.4 || ^6.4",
-        "symfony/webpack-encore-bundle": "^1.15",
-        "vimeo/psalm": "4.23.0"
+        "sylius/twig-hooks": "^0.5.1",
+        "symfony/browser-kit": "^6.4",
+        "symfony/debug-bundle": "^6.4",
+        "symfony/dotenv": "^6.4",
+        "symfony/intl": "^6.4",
+        "symfony/runtime": "^6.4 || ^7.0",
+        "symfony/ux-icons": "^2.22",
+        "symfony/web-profiler-bundle": "^6.4",
+        "symfony/webpack-encore-bundle": "^1.15 || ^2.2",
+        "vimeo/psalm": "^4.0"
     },
     "config": {
         "sort-packages": true,
@@ -46,12 +44,13 @@
             "dealerdirect/phpcodesniffer-composer-installer": true,
             "symfony/thanks": true,
             "phpstan/extension-installer": true,
-            "symfony/runtime": true
+            "symfony/runtime": true,
+            "php-http/discovery": true
         }
     },
     "extra": {
         "branch-alias": {
-            "dev-master": "2.0-dev"
+            "dev-master": "3.0-dev"
         }
     },
     "autoload": {
diff --git a/tests/Application/config/bundles.php b/tests/Application/config/bundles.php
index 97fabf12..1ffdd587 100644
--- a/tests/Application/config/bundles.php
+++ b/tests/Application/config/bundles.php
@@ -28,11 +28,6 @@
     Sylius\Bundle\CoreBundle\SyliusCoreBundle::class => ['all' => true],
     Sylius\Bundle\ResourceBundle\SyliusResourceBundle::class => ['all' => true],
     Sylius\Bundle\GridBundle\SyliusGridBundle::class => ['all' => true],
-    winzou\Bundle\StateMachineBundle\winzouStateMachineBundle::class => ['all' => true],
-    Sonata\BlockBundle\SonataBlockBundle::class => ['all' => true],
-    Bazinga\Bundle\HateoasBundle\BazingaHateoasBundle::class => ['all' => true],
-    JMS\SerializerBundle\JMSSerializerBundle::class => ['all' => true],
-    FOS\RestBundle\FOSRestBundle::class => ['all' => true],
     Knp\Bundle\GaufretteBundle\KnpGaufretteBundle::class => ['all' => true],
     Knp\Bundle\MenuBundle\KnpMenuBundle::class => ['all' => true],
     Liip\ImagineBundle\LiipImagineBundle::class => ['all' => true],
@@ -57,4 +52,6 @@
     League\FlysystemBundle\FlysystemBundle::class => ['all' => true],
     Sylius\Abstraction\StateMachine\SyliusStateMachineAbstractionBundle::class => ['all' => true],
     Sylius\Calendar\SyliusCalendarBundle::class => ['all' => true],
- ];
+    Sylius\TwigHooks\SyliusTwigHooksBundle::class => ['all' => true],
+    Symfony\UX\Icons\UXIconsBundle::class => ['all' => true],
+];
diff --git a/tests/Application/config/packages/fos_rest.yaml b/tests/Application/config/packages/fos_rest.yaml
deleted file mode 100644
index a72eef7c..00000000
--- a/tests/Application/config/packages/fos_rest.yaml
+++ /dev/null
@@ -1,11 +0,0 @@
-fos_rest:
-    exception: true
-    view:
-        formats:
-            json: true
-            xml:  true
-        empty_content: 204
-    format_listener:
-        rules:
-            - { path: '^/api/.*', priorities: ['json', 'xml'], fallback_format: json, prefer_extension: true }
-            - { path: '^/', stop: true }
diff --git a/tests/Controller/XmlApiTestCase.php b/tests/Controller/XmlApiTestCase.php
index 5425d99d..502bdecf 100644
--- a/tests/Controller/XmlApiTestCase.php
+++ b/tests/Controller/XmlApiTestCase.php
@@ -35,22 +35,13 @@ protected function generateSitemaps(): void
 
     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->doRequest($uri);
-        $response = $this->client->getResponse();
-        $contents = \ob_get_clean();
+        $this->client->request('GET', $uri);
 
-        return new Response($contents, $response->getStatusCode(), $response->headers->all());
+        return new Response(
+            $this->client->getInternalResponse()->getContent(),
+            $this->client->getInternalResponse()->getStatusCode(),
+            $this->client->getInternalResponse()->getHeaders(),
+        );
     }
 
     protected function deleteSitemaps(): void
@@ -74,9 +65,4 @@ protected function deleteSitemaps(): void
             }
         }
     }
-
-    private function doRequest(string $uri): void
-    {
-        $this->client->request('GET', $uri);
-    }
 }