From 4ab6fe79447fa6206382b3558473716236e9dd01 Mon Sep 17 00:00:00 2001 From: mamazu <14860264+mamazu@users.noreply.github.com> Date: Mon, 16 Mar 2020 13:49:41 +0100 Subject: [PATCH] Renaming the adjustment constant --- UPGRADE-2.1.md | 27 ++++++++++++++ .../Product/CustomerOptionValuePriceType.php | 5 +-- .../views/Product/_customerOptions.html.twig | 2 +- src/Services/CustomerOptionRecalculator.php | 2 +- .../src/Migrations/Version20191010092728.php | 35 +++++++++++++++++++ .../CustomerOptionRecalculatorTest.php | 2 +- 6 files changed, 66 insertions(+), 7 deletions(-) create mode 100644 UPGRADE-2.1.md create mode 100644 tests/Application/src/Migrations/Version20191010092728.php diff --git a/UPGRADE-2.1.md b/UPGRADE-2.1.md new file mode 100644 index 00000000..0df0c279 --- /dev/null +++ b/UPGRADE-2.1.md @@ -0,0 +1,27 @@ +# Upgrade from 2.0 to 2.1 +The name of the Customer Option Adjustment constant has changed. Please create a new migration with the following content: +```php +final class Version20191010092721 extends AbstractMigration +{ + public function getDescription() : string + { + return ''; + } + + public function up(Schema $schema) : void + { + // this up() migration is auto-generated, please modify it to your needs + $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.'); + + $this->addSql('UPDATE sylius_adjustment SET type = "customer_option" WHERE type = "CUSTOMER_OPTION_ADJUSTMENT"'); + } + + public function down(Schema $schema) : void + { + // this down() migration is auto-generated, please modify it to your needs + $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.'); + + $this->addSql('UPDATE sylius_adjustment SET type = "CUSTOMER_OPTION_ADJUSTMENT" WHERE type = "customer_option"'); + } +} +``` \ No newline at end of file diff --git a/src/Form/Product/CustomerOptionValuePriceType.php b/src/Form/Product/CustomerOptionValuePriceType.php index 60f0cdb5..f253ce68 100644 --- a/src/Form/Product/CustomerOptionValuePriceType.php +++ b/src/Form/Product/CustomerOptionValuePriceType.php @@ -14,7 +14,6 @@ use Brille24\SyliusCustomerOptionsPlugin\Entity\CustomerOptions\CustomerOptionInterface; use Brille24\SyliusCustomerOptionsPlugin\Entity\CustomerOptions\CustomerOptionValuePrice; -use Brille24\SyliusCustomerOptionsPlugin\Entity\Product; use Brille24\SyliusCustomerOptionsPlugin\Entity\ProductInterface; use Brille24\SyliusCustomerOptionsPlugin\Entity\Tools\DateRange; use Brille24\SyliusCustomerOptionsPlugin\Enumerations\CustomerOptionTypeEnum; @@ -120,9 +119,7 @@ static function (array $dateTime) { public function configureOptions(OptionsResolver $resolver): void { $resolver - ->setDefaults([ - 'data_class' => CustomerOptionValuePrice::class, - ]) + ->setDefaults(['data_class' => CustomerOptionValuePrice::class]) ->setDefined('product') ->setAllowedTypes('product', ProductInterface::class); } diff --git a/src/Resources/views/Product/_customerOptions.html.twig b/src/Resources/views/Product/_customerOptions.html.twig index 94a9a7b7..e6c7f3f0 100644 --- a/src/Resources/views/Product/_customerOptions.html.twig +++ b/src/Resources/views/Product/_customerOptions.html.twig @@ -6,7 +6,7 @@ {% for orderItemOption in configuration %}
{{ orderItemOption.customerOptionName }}: - {% if(orderItemOption.customerOption.type == 'file') %} + {% if(orderItemOption.customerOptionType == 'file') %} {% if 'image' in orderItemOption.customerOptionValueName %} diff --git a/src/Services/CustomerOptionRecalculator.php b/src/Services/CustomerOptionRecalculator.php index d7de5c33..a96c2e98 100644 --- a/src/Services/CustomerOptionRecalculator.php +++ b/src/Services/CustomerOptionRecalculator.php @@ -12,7 +12,7 @@ final class CustomerOptionRecalculator implements OrderProcessorInterface { - public const CUSTOMER_OPTION_ADJUSTMENT = 'CUSTOMER_OPTION_ADJUSTMENT'; + public const CUSTOMER_OPTION_ADJUSTMENT = 'customer_option'; /** @var AdjustmentFactoryInterface */ private $adjustmentFactory; diff --git a/tests/Application/src/Migrations/Version20191010092728.php b/tests/Application/src/Migrations/Version20191010092728.php new file mode 100644 index 00000000..f41a0a0a --- /dev/null +++ b/tests/Application/src/Migrations/Version20191010092728.php @@ -0,0 +1,35 @@ +abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.'); + + $this->addSql('UPDATE sylius_adjustment SET type = "customer_option" WHERE type = "CUSTOMER_OPTION_ADJUSTMENT"'); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.'); + + $this->addSql('UPDATE sylius_adjustment SET type = "CUSTOMER_OPTION_ADJUSTMENT" WHERE type = "customer_option"'); + } +} \ No newline at end of file diff --git a/tests/PHPUnit/Service/CustomerOptionRecalculatorTest.php b/tests/PHPUnit/Service/CustomerOptionRecalculatorTest.php index f9079084..cc24b8a2 100644 --- a/tests/PHPUnit/Service/CustomerOptionRecalculatorTest.php +++ b/tests/PHPUnit/Service/CustomerOptionRecalculatorTest.php @@ -80,7 +80,7 @@ public function testProcess(): void $this->adjustmentFactory ->expects($this->once()) ->method('createWithData') - ->with('CUSTOMER_OPTION_ADJUSTMENT', 'Test Adjustment', 1200) + ->with('customer_option', 'Test Adjustment', 1200) ->willReturn($adjustment) ;