Skip to content

Commit

Permalink
Renaming the adjustment constant
Browse files Browse the repository at this point in the history
  • Loading branch information
mamazu committed Mar 16, 2020
1 parent dbf41df commit 4ab6fe7
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 7 deletions.
27 changes: 27 additions & 0 deletions UPGRADE-2.1.md
Original file line number Diff line number Diff line change
@@ -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"');
}
}
```
5 changes: 1 addition & 4 deletions src/Form/Product/CustomerOptionValuePriceType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/views/Product/_customerOptions.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{% for orderItemOption in configuration %}
<div class="item" data-sylius-option-name="{{ orderItemOption.customerOptionCode }}">
{{ orderItemOption.customerOptionName }}:
{% if(orderItemOption.customerOption.type == 'file') %}
{% if(orderItemOption.customerOptionType == 'file') %}
<a href="{{ orderItemOption.customerOptionValueName }}" download>
{% if 'image' in orderItemOption.customerOptionValueName %}
<img src="{{ orderItemOption.customerOptionValueName }}" style="max-width: 200px" />
Expand Down
2 changes: 1 addition & 1 deletion src/Services/CustomerOptionRecalculator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
35 changes: 35 additions & 0 deletions tests/Application/src/Migrations/Version20191010092728.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20191010092728 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"');
}
}
2 changes: 1 addition & 1 deletion tests/PHPUnit/Service/CustomerOptionRecalculatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
;

Expand Down

0 comments on commit 4ab6fe7

Please sign in to comment.