From 9f1ead4afb07918459ea216320cc6c5d229aefb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartosz=20Wojda=C5=82owicz?= Date: Thu, 8 Feb 2024 15:18:12 +0100 Subject: [PATCH] OP-232 - configure plugin skeleton for sulu plugin --- behat.yml.dist | 2 +- composer.json | 11 +-- config/services.xml | 9 ++- config/shop_routing.yml | 13 --- .../dynamically_greeting_a_customer.feature | 17 ---- features/running_a_sylius_feature.feature | 42 ---------- .../statically_greeting_a_customer.feature | 17 ---- phpspec.yml.dist | 4 +- phpunit.xml.dist | 2 +- ...ePlugin.php => BitBagSyliusSuluPlugin.php} | 4 +- src/Controller/GreetingController.php | 33 -------- ...sion.php => BitBagSyliusSuluExtension.php} | 6 +- src/DependencyInjection/Configuration.php | 4 +- templates/dynamic_greeting.html.twig | 8 -- templates/static_greeting.html.twig | 5 -- tests/Application/.env | 4 +- tests/Application/.env.test | 2 +- tests/Application/Kernel.php | 2 +- tests/Application/bin/console | 2 +- tests/Application/config/bundles.php | 2 +- tests/Application/config/routes.yaml | 9 --- tests/Application/public/index.php | 3 +- .../Behat/Context/Ui/Shop/WelcomeContext.php | 80 ------------------- tests/Behat/Page/Shop/DynamicWelcomePage.php | 44 ---------- tests/Behat/Page/Shop/StaticWelcomePage.php | 36 --------- .../Behat/Page/Shop/WelcomePageInterface.php | 15 ---- tests/Behat/Resources/services.xml | 16 ---- tests/Behat/Resources/suites.yml | 10 --- 28 files changed, 31 insertions(+), 371 deletions(-) delete mode 100644 features/dynamically_greeting_a_customer.feature delete mode 100644 features/running_a_sylius_feature.feature delete mode 100644 features/statically_greeting_a_customer.feature rename src/{AcmeSyliusExamplePlugin.php => BitBagSyliusSuluPlugin.php} (74%) delete mode 100644 src/Controller/GreetingController.php rename src/DependencyInjection/{AcmeSyliusExampleExtension.php => BitBagSyliusSuluExtension.php} (84%) delete mode 100644 templates/dynamic_greeting.html.twig delete mode 100644 templates/static_greeting.html.twig delete mode 100644 tests/Behat/Context/Ui/Shop/WelcomeContext.php delete mode 100644 tests/Behat/Page/Shop/DynamicWelcomePage.php delete mode 100644 tests/Behat/Page/Shop/StaticWelcomePage.php delete mode 100644 tests/Behat/Page/Shop/WelcomePageInterface.php delete mode 100644 tests/Behat/Resources/services.xml delete mode 100644 tests/Behat/Resources/suites.yml diff --git a/behat.yml.dist b/behat.yml.dist index b9401b7..36014bf 100644 --- a/behat.yml.dist +++ b/behat.yml.dist @@ -46,7 +46,7 @@ default: FriendsOfBehat\SymfonyExtension: bootstrap: tests/Application/config/bootstrap.php kernel: - class: Tests\Acme\SyliusExamplePlugin\Application\Kernel + class: Tests\BitBag\SyliusSuluPlugin\Application\Kernel FriendsOfBehat\VariadicExtension: ~ diff --git a/composer.json b/composer.json index aae1f3f..59ad9d4 100644 --- a/composer.json +++ b/composer.json @@ -1,11 +1,12 @@ { - "name": "sylius/plugin-skeleton", + "name": "bitbag/sulu-plugin", "type": "sylius-plugin", - "description": "Acme example plugin for Sylius.", "keywords": [ "sylius", - "sylius-plugin" + "sylius-plugin", + "sylius-sulu-cms" ], + "description": "Sulu CMS plugin for Sylius applications.", "license": "MIT", "require": { "php": "^8.0", @@ -64,8 +65,8 @@ }, "autoload": { "psr-4": { - "Acme\\SyliusExamplePlugin\\": "src/", - "Tests\\Acme\\SyliusExamplePlugin\\": "tests/" + "BitBag\\SyliusSuluPlugin\\": "src/", + "Tests\\BitBag\\SyliusSuluPlugin\\": "tests/" } }, "autoload-dev": { diff --git a/config/services.xml b/config/services.xml index 7a3a6ac..ce93ef6 100644 --- a/config/services.xml +++ b/config/services.xml @@ -1,8 +1,11 @@ - + - - + diff --git a/config/shop_routing.yml b/config/shop_routing.yml index 7f47db1..e69de29 100644 --- a/config/shop_routing.yml +++ b/config/shop_routing.yml @@ -1,13 +0,0 @@ -# Delete these routes and define your own shop routes here - -acme_sylius_example_static_welcome: - path: /static-welcome/{name} - defaults: - _controller: Acme\SyliusExamplePlugin\Controller\GreetingController::staticallyGreetAction - name: ~ - -acme_sylius_example_dynamic_welcome: - path: /dynamic-welcome/{name} - defaults: - _controller: Acme\SyliusExamplePlugin\Controller\GreetingController::dynamicallyGreetAction - name: ~ diff --git a/features/dynamically_greeting_a_customer.feature b/features/dynamically_greeting_a_customer.feature deleted file mode 100644 index 5dc5dd7..0000000 --- a/features/dynamically_greeting_a_customer.feature +++ /dev/null @@ -1,17 +0,0 @@ -@greeting_customer @javascript -Feature: Dynamically greeting a customer - In order to provide an ultimate customer experience - As a Store Owner - I want to welcome new customers dynamically - - Scenario: Dynamically greeting a customer with an unknown name - When a customer with an unknown name visits dynamic welcome page - Then they should be dynamically greeted with "Hello!" - - Scenario: Dynamically greeting a customer with a known name - When a customer named "Krzysztof" visits dynamic welcome page - Then they should be dynamically greeted with "Hello, Krzysztof!" - - Scenario: Dynamically greeting Lionel Richie - When a customer named "Lionel Richie" visits dynamic welcome page - Then they should be dynamically greeted with "Hello, is it me you're looking for?" diff --git a/features/running_a_sylius_feature.feature b/features/running_a_sylius_feature.feature deleted file mode 100644 index 6090db1..0000000 --- a/features/running_a_sylius_feature.feature +++ /dev/null @@ -1,42 +0,0 @@ -# Sylius/Sylius:features/product/managing_products/adding_product_with_associations.feature - -@managing_products -Feature: Adding a new product with associations - In order to associate my product with others - As an Administrator - I want to add a new product with associated products - - Background: - Given the store operates on a single channel in "United States" - And the store has "Accessories" and "Alternatives" product association types - And the store has "LG headphones", "LG earphones", "LG G4" and "LG G5" products - And I am logged in as an administrator - - @ui @javascript - Scenario: Adding a new product with associations - When I want to create a new simple product - And I specify its code as "lg_g3" - And I name it "LG G3" in "English (United States)" - And I set its price to "$400.00" for "United States" channel - And I associate as "Accessories" the "LG headphones" and "LG earphones" products - And I associate as "Alternatives" the "LG G4" and "LG G5" products - And I add it - Then I should be notified that it has been successfully created - And this product should have an association "Accessories" with products "LG headphones" and "LG earphones" - And this product should also have an association "Alternatives" with products "LG G4" and "LG G5" - And the product "LG G3" should appear in the store - - @ui @javascript - Scenario: Adding a new product with associations after changing associated items - When I want to create a new simple product - And I specify its code as "lg_g3" - And I name it "LG G3" in "English (United States)" - And I set its price to "$400.00" for "United States" channel - And I associate as "Accessories" the "LG headphones" and "LG earphones" products - And I remove an associated product "LG earphones" from "Accessories" - And I add it - Then I should be notified that it has been successfully created - And this product should have an association "Accessories" with product "LG headphones" - And this product should not have an association "Accessories" with product "LG earphones" - And the product "LG G3" should appear in the store - diff --git a/features/statically_greeting_a_customer.feature b/features/statically_greeting_a_customer.feature deleted file mode 100644 index 484eb24..0000000 --- a/features/statically_greeting_a_customer.feature +++ /dev/null @@ -1,17 +0,0 @@ -@greeting_customer -Feature: Statically greeting a customer - In order to provide an ultimate customer experience - As a Store Owner - I want to welcome new customers - - Scenario: Statically greeting a customer with an unknown name - When a customer with an unknown name visits static welcome page - Then they should be statically greeted with "Hello!" - - Scenario: Statically greeting a customer with a known name - When a customer named "Krzysztof" visits static welcome page - Then they should be statically greeted with "Hello, Krzysztof!" - - Scenario: Statically greeting Lionel Richie - When a customer named "Lionel Richie" visits static welcome page - Then they should be statically greeted with "Hello, is it me you're looking for?" diff --git a/phpspec.yml.dist b/phpspec.yml.dist index ae371ee..444e04d 100644 --- a/phpspec.yml.dist +++ b/phpspec.yml.dist @@ -1,4 +1,4 @@ suites: main: - namespace: Acme\SyliusExamplePlugin - psr4_prefix: Acme\SyliusExamplePlugin + namespace: BitBag\SyliusSuluPlugin + psr4_prefix: BitBag\SyliusSuluPlugin diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 042a638..27df71e 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -5,7 +5,7 @@ colors="true" bootstrap="tests/Application/config/bootstrap.php"> - + tests diff --git a/src/AcmeSyliusExamplePlugin.php b/src/BitBagSyliusSuluPlugin.php similarity index 74% rename from src/AcmeSyliusExamplePlugin.php rename to src/BitBagSyliusSuluPlugin.php index 7b076f6..ffde7cd 100644 --- a/src/AcmeSyliusExamplePlugin.php +++ b/src/BitBagSyliusSuluPlugin.php @@ -2,12 +2,12 @@ declare(strict_types=1); -namespace Acme\SyliusExamplePlugin; +namespace BitBag\SyliusSuluPlugin; use Sylius\Bundle\CoreBundle\Application\SyliusPluginTrait; use Symfony\Component\HttpKernel\Bundle\Bundle; -final class AcmeSyliusExamplePlugin extends Bundle +final class BitBagSyliusSuluPlugin extends Bundle { use SyliusPluginTrait; diff --git a/src/Controller/GreetingController.php b/src/Controller/GreetingController.php deleted file mode 100644 index be929d0..0000000 --- a/src/Controller/GreetingController.php +++ /dev/null @@ -1,33 +0,0 @@ -render('@AcmeSyliusExamplePlugin/static_greeting.html.twig', ['greeting' => $this->getGreeting($name)]); - } - - public function dynamicallyGreetAction(?string $name): Response - { - return $this->render('@AcmeSyliusExamplePlugin/dynamic_greeting.html.twig', ['greeting' => $this->getGreeting($name)]); - } - - private function getGreeting(?string $name): string - { - switch ($name) { - case null: - return 'Hello!'; - case 'Lionel Richie': - return 'Hello, is it me you\'re looking for?'; - default: - return sprintf('Hello, %s!', $name); - } - } -} diff --git a/src/DependencyInjection/AcmeSyliusExampleExtension.php b/src/DependencyInjection/BitBagSyliusSuluExtension.php similarity index 84% rename from src/DependencyInjection/AcmeSyliusExampleExtension.php rename to src/DependencyInjection/BitBagSyliusSuluExtension.php index 5ca970b..f9577fe 100644 --- a/src/DependencyInjection/AcmeSyliusExampleExtension.php +++ b/src/DependencyInjection/BitBagSyliusSuluExtension.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Acme\SyliusExamplePlugin\DependencyInjection; +namespace BitBag\SyliusSuluPlugin\DependencyInjection; use Sylius\Bundle\CoreBundle\DependencyInjection\PrependDoctrineMigrationsTrait; use Sylius\Bundle\ResourceBundle\DependencyInjection\Extension\AbstractResourceExtension; @@ -11,7 +11,7 @@ use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface; use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; -final class AcmeSyliusExampleExtension extends AbstractResourceExtension implements PrependExtensionInterface +final class BitBagSyliusSuluExtension extends AbstractResourceExtension implements PrependExtensionInterface { use PrependDoctrineMigrationsTrait; @@ -35,7 +35,7 @@ protected function getMigrationsNamespace(): string protected function getMigrationsDirectory(): string { - return '@AcmeSyliusExamplePlugin/migrations'; + return '@BitBagSyliusSuluPlugin/Migrations'; } protected function getNamespacesOfMigrationsExecutedBefore(): array diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index 56465a1..febb2d3 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Acme\SyliusExamplePlugin\DependencyInjection; +namespace BitBag\SyliusSuluPlugin\DependencyInjection; use Symfony\Component\Config\Definition\Builder\TreeBuilder; use Symfony\Component\Config\Definition\ConfigurationInterface; @@ -14,7 +14,7 @@ final class Configuration implements ConfigurationInterface */ public function getConfigTreeBuilder(): TreeBuilder { - $treeBuilder = new TreeBuilder('acme_sylius_example_plugin'); + $treeBuilder = new TreeBuilder('bitbag_sylius_sulu_plugin'); $rootNode = $treeBuilder->getRootNode(); return $treeBuilder; diff --git a/templates/dynamic_greeting.html.twig b/templates/dynamic_greeting.html.twig deleted file mode 100644 index 743e4f2..0000000 --- a/templates/dynamic_greeting.html.twig +++ /dev/null @@ -1,8 +0,0 @@ - - - - - -
Loading...
- - diff --git a/templates/static_greeting.html.twig b/templates/static_greeting.html.twig deleted file mode 100644 index 516667f..0000000 --- a/templates/static_greeting.html.twig +++ /dev/null @@ -1,5 +0,0 @@ - - -
{{ greeting }}
- - diff --git a/tests/Application/.env b/tests/Application/.env index 888c0b3..3288c4e 100644 --- a/tests/Application/.env +++ b/tests/Application/.env @@ -12,13 +12,13 @@ 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=mysql://root@127.0.0.1/acme_sylius_example_plugin_%kernel.environment%?serverVersion=5.7 +DATABASE_URL=mysql://root@127.0.0.1/bitbag_sulu_sylius_plugin_%kernel.environment%?serverVersion=5.7 ###< doctrine/doctrine-bundle ### ###> lexik/jwt-authentication-bundle ### JWT_SECRET_KEY=%kernel.project_dir%/config/jwt/private.pem JWT_PUBLIC_KEY=%kernel.project_dir%/config/jwt/public.pem -JWT_PASSPHRASE=acme_plugin_development +JWT_PASSPHRASE=YOUR_SECRET_PASSPHRASE ###< lexik/jwt-authentication-bundle ### ###> symfony/mailer ### diff --git a/tests/Application/.env.test b/tests/Application/.env.test index 62d1bee..6fdfd07 100644 --- a/tests/Application/.env.test +++ b/tests/Application/.env.test @@ -1,6 +1,6 @@ APP_SECRET='ch4mb3r0f5ecr3ts' -KERNEL_CLASS='Tests\Acme\SyliusExamplePlugin\Application\Kernel' +KERNEL_CLASS='Tests\BitBag\SyliusSuluPlugin\Application\Kernel' ###> symfony/messenger ### # Sync transport turned for testing env for the ease of testing diff --git a/tests/Application/Kernel.php b/tests/Application/Kernel.php index 0bedc86..30f65c7 100644 --- a/tests/Application/Kernel.php +++ b/tests/Application/Kernel.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Tests\Acme\SyliusExamplePlugin\Application; +namespace Tests\BitBag\SyliusSuluPlugin\Application; use PSS\SymfonyMockerContainer\DependencyInjection\MockerContainer; use Sylius\Bundle\CoreBundle\Application\Kernel as SyliusKernel; diff --git a/tests/Application/bin/console b/tests/Application/bin/console index bf889e9..39ecde4 100755 --- a/tests/Application/bin/console +++ b/tests/Application/bin/console @@ -1,7 +1,7 @@ #!/usr/bin/env php ['all' => true], Sylius\Bundle\AdminBundle\SyliusAdminBundle::class => ['all' => true], Sylius\Bundle\ShopBundle\SyliusShopBundle::class => ['all' => true], - Acme\SyliusExamplePlugin\AcmeSyliusExamplePlugin::class => ['all' => true], + BitBag\SyliusSuluPlugin\BitBagSyliusSuluPlugin::class => ['all' => true], Symfony\Bundle\DebugBundle\DebugBundle::class => ['dev' => true, 'test' => true, 'test_cached' => true], Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true, 'test_cached' => true], FriendsOfBehat\SymfonyExtension\Bundle\FriendsOfBehatSymfonyExtensionBundle::class => ['test' => true, 'test_cached' => true], diff --git a/tests/Application/config/routes.yaml b/tests/Application/config/routes.yaml index 876801b..e69de29 100644 --- a/tests/Application/config/routes.yaml +++ b/tests/Application/config/routes.yaml @@ -1,9 +0,0 @@ -acme_sylius_example_shop: - resource: "@AcmeSyliusExamplePlugin/config/shop_routing.yml" - prefix: /{_locale} - requirements: - _locale: ^[a-z]{2}(?:_[A-Z]{2})?$ - -acme_sylius_example_admin: - resource: "@AcmeSyliusExamplePlugin/config/admin_routing.yml" - prefix: /admin diff --git a/tests/Application/public/index.php b/tests/Application/public/index.php index af4ad7e..931e54e 100644 --- a/tests/Application/public/index.php +++ b/tests/Application/public/index.php @@ -2,9 +2,10 @@ declare(strict_types=1); -use Tests\Acme\SyliusExamplePlugin\Application\Kernel; use Symfony\Component\ErrorHandler\Debug; use Symfony\Component\HttpFoundation\Request; +use Tests\BitBag\SyliusSuluPlugin\Application\Kernel; + require dirname(__DIR__) . '/config/bootstrap.php'; diff --git a/tests/Behat/Context/Ui/Shop/WelcomeContext.php b/tests/Behat/Context/Ui/Shop/WelcomeContext.php deleted file mode 100644 index a0d95b0..0000000 --- a/tests/Behat/Context/Ui/Shop/WelcomeContext.php +++ /dev/null @@ -1,80 +0,0 @@ -staticWelcomePage = $staticWelcomePage; - $this->dynamicWelcomePage = $dynamicWelcomePage; - } - - /** - * @When a customer with an unknown name visits static welcome page - */ - public function customerWithUnknownNameVisitsStaticWelcomePage(): void - { - $this->staticWelcomePage->open(); - } - - /** - * @When a customer named :name visits static welcome page - */ - public function namedCustomerVisitsStaticWelcomePage(string $name): void - { - $this->staticWelcomePage->open(['name' => $name]); - } - - /** - * @Then they should be statically greeted with :greeting - */ - public function theyShouldBeStaticallyGreetedWithGreeting(string $greeting): void - { - Assert::same($this->staticWelcomePage->getGreeting(), $greeting); - } - - /** - * @When a customer with an unknown name visits dynamic welcome page - */ - public function customerWithUnknownNameVisitsDynamicWelcomePage(): void - { - $this->dynamicWelcomePage->open(); - } - - /** - * @When a customer named :name visits dynamic welcome page - */ - public function namedCustomerVisitsDynamicWelcomePage(string $name): void - { - $this->dynamicWelcomePage->open(['name' => $name]); - } - - /** - * @Then they should be dynamically greeted with :greeting - */ - public function theyShouldBeDynamicallyGreetedWithGreeting(string $greeting): void - { - Assert::same($this->dynamicWelcomePage->getGreeting(), $greeting); - } -} diff --git a/tests/Behat/Page/Shop/DynamicWelcomePage.php b/tests/Behat/Page/Shop/DynamicWelcomePage.php deleted file mode 100644 index 08e5f8c..0000000 --- a/tests/Behat/Page/Shop/DynamicWelcomePage.php +++ /dev/null @@ -1,44 +0,0 @@ -getSession()->getPage()->waitFor(3, function (): string { - $greeting = $this->getElement('greeting')->getText(); - - if ('Loading...' === $greeting) { - return ''; - } - - return $greeting; - }); - } - - /** - * {@inheritdoc} - */ - public function getRouteName(): string - { - return 'acme_sylius_example_dynamic_welcome'; - } - - /** - * {@inheritdoc} - */ - protected function getDefinedElements(): array - { - return array_merge(parent::getDefinedElements(), [ - 'greeting' => '#greeting', - ]); - } -} diff --git a/tests/Behat/Page/Shop/StaticWelcomePage.php b/tests/Behat/Page/Shop/StaticWelcomePage.php deleted file mode 100644 index 8f2a96b..0000000 --- a/tests/Behat/Page/Shop/StaticWelcomePage.php +++ /dev/null @@ -1,36 +0,0 @@ -getElement('greeting')->getText(); - } - - /** - * {@inheritdoc} - */ - public function getRouteName(): string - { - return 'acme_sylius_example_static_welcome'; - } - - /** - * {@inheritdoc} - */ - protected function getDefinedElements(): array - { - return array_merge(parent::getDefinedElements(), [ - 'greeting' => '#greeting', - ]); - } -} diff --git a/tests/Behat/Page/Shop/WelcomePageInterface.php b/tests/Behat/Page/Shop/WelcomePageInterface.php deleted file mode 100644 index 7cd873c..0000000 --- a/tests/Behat/Page/Shop/WelcomePageInterface.php +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/tests/Behat/Resources/suites.yml b/tests/Behat/Resources/suites.yml deleted file mode 100644 index 6cfe415..0000000 --- a/tests/Behat/Resources/suites.yml +++ /dev/null @@ -1,10 +0,0 @@ -# Put your Behat suites definitions here - -default: - suites: - greeting_customer: - contexts: - - acme_sylius_example.context.ui.shop.welcome - - filters: - tags: "@greeting_customer"