Merge pull request #3536 from PWalkow/order-rename-of-label-on-adjustment-to-type

[Order,Core,Web] Rename of label on adjustment to type
This commit is contained in:
Paweł Jędrzejewski 2015-11-06 20:38:38 +01:00
commit e3675dca62
22 changed files with 75 additions and 40 deletions

View file

@ -9,6 +9,7 @@ To get the diff between two versions, go to https://github.com/Sylius/Sylius/com
* feature #3110 [BC BREAK] Bumped minimal versions, major changes: PHP >=5.5.9, Symfony ^2.7
* bc break #3364 [BC BREAK] Renamed setDefaultOptions to configureOptions
* bc break #3536 [BC BREAK] Renamed label to type on adjustment
## v0.15 (2015-09-08)

View file

@ -0,0 +1,34 @@
<?php
namespace Sylius\Migrations;
use Doctrine\DBAL\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your needs!
*/
class Version20151019160305 extends AbstractMigration
{
/**
* @param Schema $schema
*/
public function up(Schema $schema)
{
// 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('ALTER TABLE sylius_adjustment CHANGE label type VARCHAR(255) NOT NULL');
}
/**
* @param Schema $schema
*/
public function down(Schema $schema)
{
// 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('ALTER TABLE sylius_adjustment CHANGE type label VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci');
}
}

View file

@ -150,7 +150,7 @@ class TaxationProcessor implements TaxationProcessorInterface
{
foreach ($taxes as $description => $tax) {
$adjustment = $this->adjustmentRepository->createNew();
$adjustment->setLabel(AdjustmentInterface::TAX_ADJUSTMENT);
$adjustment->setType(AdjustmentInterface::TAX_ADJUSTMENT);
$adjustment->setAmount($tax['amount']);
$adjustment->setDescription($description);
$adjustment->setNeutral($tax['included']);

View file

@ -27,8 +27,8 @@ class AdjustmentType extends AbstractResourceType
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('label', 'text', array(
'label' => 'sylius.form.adjustment.label'
->add('type', 'text', array(
'label' => 'sylius.form.adjustment.type'
))
->add('description', 'text', array(
'label' => 'sylius.form.adjustment.description',

View file

@ -22,7 +22,7 @@
<generator strategy="AUTO" />
</id>
<field name="label" column="label" type="string" />
<field name="type" column="type" type="string" />
<field name="description" column="description" type="string" nullable="true" />
<field name="amount" column="amount" type="integer" />
<field name="neutral" column="is_neutral" type="boolean" />

View file

@ -42,9 +42,9 @@
</class>
<class name="Sylius\Component\Order\Model\Adjustment">
<property name="label">
<property name="type">
<constraint name="NotBlank">
<option name="message">sylius.adjustment.label.not_blank</option>
<option name="message">sylius.adjustment.type.not_blank</option>
<option name="groups">sylius</option>
</constraint>
</property>

View file

@ -39,7 +39,7 @@ class AdjustmentTypeSpec extends ObjectBehavior
function it_builds_form_with_proper_fields(FormBuilderInterface $builder)
{
$builder
->add('label', 'text', Argument::any())
->add('type', 'text', Argument::any())
->willReturn($builder)
;

View file

@ -578,7 +578,7 @@ sylius:
no_promotion: No coupons were used.order:
adjustments:
manage: Manage adjustments
label: Label
type: Type
description: Description
amount: Amount
locked: Locked?

View file

@ -38,7 +38,7 @@
<table class="table">
<thead>
<tr>
<th>{{ 'sylius.order.adjustments.label'|trans }}</th>
<th>{{ 'sylius.order.adjustments.type'|trans }}</th>
<th>{{ 'sylius.order.adjustments.description'|trans }}</th>
<th>{{ 'sylius.order.adjustments.amount'|trans }}</th>
<th>{{ 'sylius.order.adjustments.locked'|trans }}</th>
@ -49,7 +49,7 @@
{% for adjustment in order.adjustments %}
<tr>
<td>
{{ adjustment.label }}
{{ adjustment.type }}
</td>
<td>
{{ adjustment.description }}

View file

@ -78,7 +78,7 @@ class PaymentChargesProcessor implements PaymentChargesProcessorInterface
private function prepareAdjustmentForOrder(PaymentSubjectInterface $payment)
{
$adjustment = $this->adjustmentRepository->createNew();
$adjustment->setLabel(AdjustmentInterface::PAYMENT_ADJUSTMENT);
$adjustment->setType(AdjustmentInterface::PAYMENT_ADJUSTMENT);
$adjustment->setAmount($this->feeCalculator->calculate($payment));
$adjustment->setDescription($payment->getMethod()->getName());

View file

@ -61,7 +61,7 @@ class ShippingChargesProcessor implements ShippingChargesProcessorInterface
$shippingCharge = $this->calculator->calculate($shipment);
$adjustment = $this->adjustmentRepository->createNew();
$adjustment->setLabel(AdjustmentInterface::SHIPPING_ADJUSTMENT);
$adjustment->setType(AdjustmentInterface::SHIPPING_ADJUSTMENT);
$adjustment->setAmount($shippingCharge);
$adjustment->setDescription($shipment->getMethod()->getName());

View file

@ -64,7 +64,7 @@ abstract class DiscountAction implements PromotionActionInterface
protected function createAdjustment(PromotionInterface $promotion)
{
$adjustment = $this->adjustmentRepository->createNew();
$adjustment->setLabel(AdjustmentInterface::PROMOTION_ADJUSTMENT);
$adjustment->setType(AdjustmentInterface::PROMOTION_ADJUSTMENT);
$adjustment->setDescription($promotion->getDescription());
$this->originator->setOrigin($adjustment, $promotion);

View file

@ -110,10 +110,10 @@ class OrderSpec extends ObjectBehavior
AdjustmentInterface $shippingAdjustment,
AdjustmentInterface $taxAdjustment
) {
$shippingAdjustment->getLabel()->willReturn(AdjustmentInterface::SHIPPING_ADJUSTMENT);
$shippingAdjustment->getType()->willReturn(AdjustmentInterface::SHIPPING_ADJUSTMENT);
$shippingAdjustment->setAdjustable($this)->shouldBeCalled();
$taxAdjustment->getLabel()->willReturn(AdjustmentInterface::TAX_ADJUSTMENT);
$taxAdjustment->getType()->willReturn(AdjustmentInterface::TAX_ADJUSTMENT);
$taxAdjustment->setAdjustable($this)->shouldBeCalled();
$this->addAdjustment($shippingAdjustment);
@ -130,10 +130,10 @@ class OrderSpec extends ObjectBehavior
AdjustmentInterface $shippingAdjustment,
AdjustmentInterface $taxAdjustment
) {
$shippingAdjustment->getLabel()->willReturn(AdjustmentInterface::SHIPPING_ADJUSTMENT);
$shippingAdjustment->getType()->willReturn(AdjustmentInterface::SHIPPING_ADJUSTMENT);
$shippingAdjustment->setAdjustable($this)->shouldBeCalled();
$taxAdjustment->getLabel()->willReturn(AdjustmentInterface::TAX_ADJUSTMENT);
$taxAdjustment->getType()->willReturn(AdjustmentInterface::TAX_ADJUSTMENT);
$taxAdjustment->setAdjustable($this)->shouldBeCalled();
$this->addAdjustment($shippingAdjustment);
@ -153,10 +153,10 @@ class OrderSpec extends ObjectBehavior
AdjustmentInterface $shippingAdjustment,
AdjustmentInterface $taxAdjustment
) {
$shippingAdjustment->getLabel()->willReturn(AdjustmentInterface::SHIPPING_ADJUSTMENT);
$shippingAdjustment->getType()->willReturn(AdjustmentInterface::SHIPPING_ADJUSTMENT);
$shippingAdjustment->setAdjustable($this)->shouldBeCalled();
$taxAdjustment->getLabel()->willReturn(AdjustmentInterface::TAX_ADJUSTMENT);
$taxAdjustment->getType()->willReturn(AdjustmentInterface::TAX_ADJUSTMENT);
$taxAdjustment->setAdjustable($this)->shouldBeCalled();
$this->addAdjustment($shippingAdjustment);
@ -173,10 +173,10 @@ class OrderSpec extends ObjectBehavior
AdjustmentInterface $shippingAdjustment,
AdjustmentInterface $taxAdjustment
) {
$shippingAdjustment->getLabel()->willReturn(AdjustmentInterface::SHIPPING_ADJUSTMENT);
$shippingAdjustment->getType()->willReturn(AdjustmentInterface::SHIPPING_ADJUSTMENT);
$shippingAdjustment->setAdjustable($this)->shouldBeCalled();
$taxAdjustment->getLabel()->willReturn(AdjustmentInterface::TAX_ADJUSTMENT);
$taxAdjustment->getType()->willReturn(AdjustmentInterface::TAX_ADJUSTMENT);
$taxAdjustment->setAdjustable($this)->shouldBeCalled();
$this->addAdjustment($shippingAdjustment);

View file

@ -59,7 +59,7 @@ class PaymentChargesProcessorSpec extends ObjectBehavior
$delegatingFeeCalculator->calculate($payment)->willReturn(50);
$adjustmentRepository->createNew()->willReturn($adjustment)->shouldBeCalled();
$adjustment->setLabel('payment')->shouldBeCalled();
$adjustment->setType('payment')->shouldBeCalled();
$adjustment->setAmount(50)->shouldBeCalled();
$adjustment->setDescription('testPaymentMethod')->shouldBeCalled();

View file

@ -81,7 +81,7 @@ class ShippingChargesProcessorSpec extends ObjectBehavior
$shippingMethod->getName()->willReturn('FedEx');
$adjustment->setAmount(450)->shouldBeCalled();
$adjustment->setLabel(AdjustmentInterface::SHIPPING_ADJUSTMENT)->shouldBeCalled();
$adjustment->setType(AdjustmentInterface::SHIPPING_ADJUSTMENT)->shouldBeCalled();
$adjustment->setDescription('FedEx')->shouldBeCalled();
$order->removeAdjustments(AdjustmentInterface::SHIPPING_ADJUSTMENT)->shouldBeCalled();

View file

@ -50,7 +50,7 @@ class FixedDiscountActionSpec extends ObjectBehavior
$promotion->getDescription()->willReturn('promotion description');
$adjustment->setAmount(-500)->shouldBeCalled();
$adjustment->setLabel(AdjustmentInterface::PROMOTION_ADJUSTMENT)->shouldBeCalled();
$adjustment->setType(AdjustmentInterface::PROMOTION_ADJUSTMENT)->shouldBeCalled();
$adjustment->setDescription('promotion description')->shouldBeCalled();
$originator->setOrigin($adjustment, $promotion)->shouldBeCalled();

View file

@ -51,7 +51,7 @@ class PercentageDiscountActionSpec extends ObjectBehavior
$promotion->getDescription()->willReturn('promotion description');
$adjustment->setAmount(-2500)->shouldBeCalled();
$adjustment->setLabel(AdjustmentInterface::PROMOTION_ADJUSTMENT)->shouldBeCalled();
$adjustment->setType(AdjustmentInterface::PROMOTION_ADJUSTMENT)->shouldBeCalled();
$adjustment->setDescription('promotion description')->shouldBeCalled();
$originator->setOrigin($adjustment, $promotion)->shouldBeCalled();

View file

@ -34,7 +34,7 @@ class Adjustment implements AdjustmentInterface
/**
* @var string
*/
protected $label;
protected $type;
/**
* @var string
@ -127,17 +127,17 @@ class Adjustment implements AdjustmentInterface
/**
* {@inheritdoc}
*/
public function getLabel()
public function getType()
{
return $this->label;
return $this->type;
}
/**
* {@inheritdoc}
*/
public function setLabel($label)
public function setType($type)
{
$this->label = $label;
$this->type = $type;
}
/**

View file

@ -32,12 +32,12 @@ interface AdjustmentInterface extends TimestampableInterface, OriginAwareInterfa
/**
* @return string
*/
public function getLabel();
public function getType();
/**
* @param string $label
* @param string $type
*/
public function setLabel($label);
public function setType($type);
/**
* @return string

View file

@ -282,7 +282,7 @@ class Order implements OrderInterface
}
return $this->adjustments->filter(function (AdjustmentInterface $adjustment) use ($type) {
return $type === $adjustment->getLabel();
return $type === $adjustment->getType();
});
}

View file

@ -144,7 +144,7 @@ class OrderItem implements OrderItemInterface
}
return $this->adjustments->filter(function (AdjustmentInterface $adjustment) use ($type) {
return $type === $adjustment->getLabel();
return $type === $adjustment->getType();
});
}

View file

@ -65,15 +65,15 @@ class AdjustmentSpec extends ObjectBehavior
$this->getAdjustable()->shouldReturn(null);
}
function it_has_no_label_by_default()
function it_has_no_type_by_default()
{
$this->getLabel()->shouldReturn(null);
$this->getType()->shouldReturn(null);
}
function its_label_is_mutable()
function its_type_is_mutable()
{
$this->setLabel('Shipping Fee');
$this->getLabel()->shouldReturn('Shipping Fee');
$this->setType('some type');
$this->getType()->shouldReturn('some type');
}
function it_has_no_description_by_default()