From 1fac1e2bfdc4ef1915c685a092e1cb7c9ee36d86 Mon Sep 17 00:00:00 2001 From: Luca Gallinari Date: Mon, 27 Nov 2023 12:50:46 +0100 Subject: [PATCH] Test for other decoration strategy --- tests/Application/config/services_test.yaml | 35 +++++++++++++ .../Command/ServiceChangesCommandTest.php | 51 +++++++++++++++++++ .../git.diff | 14 +++++ .../git.diff | 14 +++++ .../DecorateSendOrderConfirmationHandler.php | 9 ++++ ...teSendShipmentConfirmationEmailHandler.php | 9 ++++ .../DecorateCustomerOrderAddressesSaver.php | 14 +++++ .../DecorateOrderPaymentProcessor.php | 14 +++++ .../DecorateProvinceNamingProvider.php | 14 +++++ 9 files changed, 174 insertions(+) create mode 100644 tests/Integration/DataFixtures/Command/ServiceChangesCommandTest/test_it_detects_with_alias_strategy_those_directly_decorated_services_that_changed/git.diff create mode 100644 tests/Integration/DataFixtures/Command/ServiceChangesCommandTest/test_it_detects_with_decorated_definition_strategy_those_directly_decorated_services_that_changed/git.diff create mode 100644 tests/Stub/ServiceChangesCommand/test_it_detects_with_alias_strategy_those_directly_decorated_services_that_changed/DecorateSendOrderConfirmationHandler.php create mode 100644 tests/Stub/ServiceChangesCommand/test_it_detects_with_alias_strategy_those_directly_decorated_services_that_changed/DecorateSendShipmentConfirmationEmailHandler.php create mode 100644 tests/Stub/ServiceChangesCommand/test_it_detects_with_decorated_definition_strategy_those_directly_decorated_services_that_changed/DecorateCustomerOrderAddressesSaver.php create mode 100644 tests/Stub/ServiceChangesCommand/test_it_detects_with_decorated_definition_strategy_those_directly_decorated_services_that_changed/DecorateOrderPaymentProcessor.php create mode 100644 tests/Stub/ServiceChangesCommand/test_it_detects_with_decorated_definition_strategy_those_directly_decorated_services_that_changed/DecorateProvinceNamingProvider.php diff --git a/tests/Application/config/services_test.yaml b/tests/Application/config/services_test.yaml index 9c2c7c0..be6d76e 100644 --- a/tests/Application/config/services_test.yaml +++ b/tests/Application/config/services_test.yaml @@ -41,3 +41,38 @@ services: webgriffe_sylius_upgrade.service_changes_command.test_it_detects_directly_decorated_services_that_changed.decorate_customer_unique_address_adder: class: Tests\Webgriffe\SyliusUpgradePlugin\Stub\ServiceChangesCommand\test_it_detects_directly_decorated_services_that_changed\DecorateCustomerUniqueAddressAdder decorates: sylius.customer_unique_address_adder + + + ## test_it_detects_with_decorated_definition_strategy_those_directly_decorated_services_that_changed + webgriffe_sylius_upgrade.service_changes_command.test_it_detects_with_decorated_definition_strategy_those_directly_decorated_services_that_changed.decorate_province_naming_provider: + public: true + class: Tests\Webgriffe\SyliusUpgradePlugin\Stub\ServiceChangesCommand\test_it_detects_with_decorated_definition_strategy_those_directly_decorated_services_that_changed\DecorateProvinceNamingProvider + decorates: sylius.province_naming_provider + arguments: + - '@.inner' + + webgriffe_sylius_upgrade.service_changes_command.test_it_detects_with_decorated_definition_strategy_those_directly_decorated_services_that_changed.decorate_order_payment_processor: + public: true + class: Tests\Webgriffe\SyliusUpgradePlugin\Stub\ServiceChangesCommand\test_it_detects_with_decorated_definition_strategy_those_directly_decorated_services_that_changed\DecorateOrderPaymentProcessor + decorates: sylius.order_processing.order_payment_processor.after_checkout + decoration_priority: 100 + arguments: + - '@.inner' + + # decorated BUT not changed + webgriffe_sylius_upgrade.service_changes_command.test_it_detects_with_decorated_definition_strategy_those_directly_decorated_services_that_changed.decorate_customer_order_addresses_saver: + class: Tests\Webgriffe\SyliusUpgradePlugin\Stub\ServiceChangesCommand\test_it_detects_with_decorated_definition_strategy_those_directly_decorated_services_that_changed\DecorateCustomerOrderAddressesSaver + decorates: sylius.customer_order_addresses_saver + arguments: + - '@.inner' + + + ## test_it_detects_with_alias_strategy_those_directly_decorated_services_that_changed + webgriffe_sylius_upgrade.service_changes_command.test_it_detects_with_alias_strategy_those_directly_decorated_services_that_changed.decorate_send_order_confirmation: + class: Tests\Webgriffe\SyliusUpgradePlugin\Stub\ServiceChangesCommand\test_it_detects_with_alias_strategy_those_directly_decorated_services_that_changed\DecorateSendOrderConfirmationHandler + decorates: Sylius\Bundle\ApiBundle\CommandHandler\Checkout\SendOrderConfirmationHandler + + # decorated BUT not changed + webgriffe_sylius_upgrade.service_changes_command.test_it_detects_with_alias_strategy_those_directly_decorated_services_that_changed.decorate_send_shipment_confirmation_email_handler: + class: Tests\Webgriffe\SyliusUpgradePlugin\Stub\ServiceChangesCommand\test_it_detects_with_alias_strategy_those_directly_decorated_services_that_changed\DecorateSendShipmentConfirmationEmailHandler + decorates: Sylius\Bundle\ApiBundle\CommandHandler\Checkout\SendShipmentConfirmationEmailHandler diff --git a/tests/Integration/Command/ServiceChangesCommandTest.php b/tests/Integration/Command/ServiceChangesCommandTest.php index 9d47796..203972a 100644 --- a/tests/Integration/Command/ServiceChangesCommandTest.php +++ b/tests/Integration/Command/ServiceChangesCommandTest.php @@ -56,6 +56,57 @@ public function test_it_detects_directly_decorated_services_that_changed(): void Service "Tests\Webgriffe\SyliusUpgradePlugin\Stub\ServiceChangesCommand\\test_it_detects_directly_decorated_services_that_changed\DecorateOrderEmailManagerInterface" must be checked because the service that it decorates "Sylius\Bundle\AdminBundle\EmailManager\OrderEmailManager" has changed between given versions Service "Tests\Webgriffe\SyliusUpgradePlugin\Stub\ServiceChangesCommand\\test_it_detects_directly_decorated_services_that_changed\DecorateNewShopBased" must be checked because the service that it decorates "Sylius\Component\Core\Cart\Context\ShopBasedCartContext" has changed between given versions +TXT; + + self::assertEquals($expectedOutput, $output); + } + + public function test_it_detects_with_decorated_definition_strategy_those_directly_decorated_services_that_changed(): void + { + Git::$diffToReturn = file_get_contents(self::FIXTURE_DIR . $this->getName() . '/git.diff'); + + $result = $this->commandTester->execute( + [ + ServiceChangesCommand::FROM_VERSION_ARGUMENT_NAME => '1.11.0', + ServiceChangesCommand::TO_VERSION_ARGUMENT_NAME => '1.12.0', + '--' . ServiceChangesCommand::NAMESPACE_PREFIX_OPTION_NAME => 'Tests', + '--' . ServiceChangesCommand::ALIAS_PREFIX_OPTION_NAME => 'webgriffe_sylius_upgrade', + ], + ); + + self::assertEquals(0, $result); + + $output = $this->commandTester->getDisplay(); + $expectedOutput = <<getName() . '/git.diff'); + + $result = $this->commandTester->execute( + [ + ServiceChangesCommand::FROM_VERSION_ARGUMENT_NAME => '1.11.0', + ServiceChangesCommand::TO_VERSION_ARGUMENT_NAME => '1.12.0', + '--' . ServiceChangesCommand::NAMESPACE_PREFIX_OPTION_NAME => 'Tests', + '--' . ServiceChangesCommand::ALIAS_PREFIX_OPTION_NAME => 'webgriffe_sylius_upgrade', + ], + ); + + self::assertEquals(0, $result); + + $output = $this->commandTester->getDisplay(); + $expectedOutput = <<