Skip to content

Commit

Permalink
Test for other decoration strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
LucaGallinari committed Nov 27, 2023
1 parent fa0c406 commit 1fac1e2
Show file tree
Hide file tree
Showing 9 changed files with 174 additions and 0 deletions.
35 changes: 35 additions & 0 deletions tests/Application/config/services_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
51 changes: 51 additions & 0 deletions tests/Integration/Command/ServiceChangesCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = <<<TXT
Computing modified services between 1.11.0 and 1.12.0
Service "webgriffe_sylius_upgrade.service_changes_command.test_it_detects_with_decorated_definition_strategy_those_directly_decorated_services_that_changed.decorate_province_naming_provider" must be checked because the service that it decorates "Sylius\Component\Addressing\Provider\ProvinceNamingProvider" has changed between given versions
Service "webgriffe_sylius_upgrade.service_changes_command.test_it_detects_with_decorated_definition_strategy_those_directly_decorated_services_that_changed.decorate_order_payment_processor" must be checked because the service that it decorates "Sylius\Component\Core\OrderProcessing\OrderPaymentProcessor" has changed between given versions
TXT;

self::assertEquals($expectedOutput, $output);
}

public function test_it_detects_with_alias_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 = <<<TXT
Computing modified services between 1.11.0 and 1.12.0
Service "Tests\Webgriffe\SyliusUpgradePlugin\Stub\ServiceChangesCommand\\test_it_detects_with_alias_strategy_those_directly_decorated_services_that_changed\DecorateSendOrderConfirmationHandler" must be checked because the service that it decorates "Sylius\Bundle\ApiBundle\CommandHandler\Checkout\SendOrderConfirmationHandler" has changed between given versions
TXT;

self::assertEquals($expectedOutput, $output);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
diff --git a/src/Sylius/Bundle/ApiBundle/CommandHandler/Checkout/SendOrderConfirmationHandler.php b/src/Sylius/Bundle/ApiBundle/CommandHandler/Checkout/SendOrderConfirmationHandler.php
index 4eaff957874..60d2decf5e8 100644
--- a/src/Sylius/Bundle/ApiBundle/CommandHandler/Checkout/SendOrderConfirmationHandler.php
+++ b/src/Sylius/Bundle/ApiBundle/CommandHandler/Checkout/SendOrderConfirmationHandler.php

diff --git a/src/Sylius/Bundle/AdminBundle/EmailManager/ShipmentEmailManager.php b/src/Sylius/Bundle/AdminBundle/EmailManager/ShipmentEmailManager.php
index 5270cc23123..02f6b26fcf7 100644
--- a/src/Sylius/Bundle/AdminBundle/EmailManager/ShipmentEmailManager.php
+++ b/src/Sylius/Bundle/AdminBundle/EmailManager/ShipmentEmailManager.php

diff --git a/src/Sylius/Bundle/AdminBundle/Event/OrderShowMenuBuilderEvent.php b/src/Sylius/Bundle/AdminBundle/Event/OrderShowMenuBuilderEvent.php
index 7e2cfde7545..da90d9fd52c 100644
--- a/src/Sylius/Bundle/AdminBundle/Event/OrderShowMenuBuilderEvent.php
+++ b/src/Sylius/Bundle/AdminBundle/Event/OrderShowMenuBuilderEvent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
diff --git a/src/Sylius/Component/Addressing/Provider/ProvinceNamingProvider.php b/src/Sylius/Component/Addressing/Provider/ProvinceNamingProvider.php
index 4eaff957874..60d2decf5e8 100644
--- a/src/Sylius/Component/Addressing/Provider/ProvinceNamingProvider.php
+++ b/src/Sylius/Component/Addressing/Provider/ProvinceNamingProvider.php

diff --git a/src/Sylius/Bundle/AdminBundle/EmailManager/ShipmentEmailManager.php b/src/Sylius/Bundle/AdminBundle/EmailManager/ShipmentEmailManager.php
index 5270cc23123..02f6b26fcf7 100644
--- a/src/Sylius/Bundle/AdminBundle/EmailManager/ShipmentEmailManager.php
+++ b/src/Sylius/Bundle/AdminBundle/EmailManager/ShipmentEmailManager.php

diff --git a/src/Sylius/Component/Core/OrderProcessing/OrderPaymentProcessor.php b/src/Sylius/Component/Core/OrderProcessing/OrderPaymentProcessor.php
index 7e2cfde7545..da90d9fd52c 100644
--- a/src/Sylius/Component/Core/OrderProcessing/OrderPaymentProcessor.php
+++ b/src/Sylius/Component/Core/OrderProcessing/OrderPaymentProcessor.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

declare(strict_types=1);

namespace Tests\Webgriffe\SyliusUpgradePlugin\Stub\ServiceChangesCommand\test_it_detects_with_alias_strategy_those_directly_decorated_services_that_changed;

final class DecorateSendOrderConfirmationHandler
{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

declare(strict_types=1);

namespace Tests\Webgriffe\SyliusUpgradePlugin\Stub\ServiceChangesCommand\test_it_detects_with_alias_strategy_those_directly_decorated_services_that_changed;

final class DecorateSendShipmentConfirmationEmailHandler
{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

declare(strict_types=1);

namespace Tests\Webgriffe\SyliusUpgradePlugin\Stub\ServiceChangesCommand\test_it_detects_with_decorated_definition_strategy_those_directly_decorated_services_that_changed;

use Sylius\Component\Core\Customer\OrderAddressesSaverInterface;

final class DecorateCustomerOrderAddressesSaver
{
public function __construct(private OrderAddressesSaverInterface $decoratedCustomerOrderAddressesSaver)
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

declare(strict_types=1);

namespace Tests\Webgriffe\SyliusUpgradePlugin\Stub\ServiceChangesCommand\test_it_detects_with_decorated_definition_strategy_those_directly_decorated_services_that_changed;

use Sylius\Component\Order\Processor\OrderProcessorInterface;

final class DecorateOrderPaymentProcessor
{
public function __construct(private OrderProcessorInterface $decoratedAfterCheckoutOrderPaymentProcessor)
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

declare(strict_types=1);

namespace Tests\Webgriffe\SyliusUpgradePlugin\Stub\ServiceChangesCommand\test_it_detects_with_decorated_definition_strategy_those_directly_decorated_services_that_changed;

use Sylius\Component\Addressing\Provider\ProvinceNamingProvider as BaseProvinceNamingProvider;

final class DecorateProvinceNamingProvider
{
public function __construct(private BaseProvinceNamingProvider $baseProvinceNamingProvider)
{
}
}

0 comments on commit 1fac1e2

Please sign in to comment.