Skip to content

Commit

Permalink
Fixes in taxes applicators
Browse files Browse the repository at this point in the history
  • Loading branch information
GSadee committed Jan 18, 2021
1 parent ba38ea9 commit 4336015
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 11 deletions.
1 change: 0 additions & 1 deletion spec/TaxesApplicator/OrderItemUnitsTaxesApplicatorSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@ function it_does_not_apply_taxes_with_amount_0(
$items->getIterator()->willReturn(new \ArrayIterator([$orderItem->getWrappedObject()]));

$orderItem->getQuantity()->willReturn(2);

$orderItem->getVariant()->willReturn($productVariant);
$taxRateResolver->resolve($productVariant, ['zone' => $zone])->willReturn($taxRate);

Expand Down
9 changes: 3 additions & 6 deletions spec/TaxesApplicator/OrderItemsTaxesApplicatorSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
use Sylius\Component\Addressing\Model\ZoneInterface;
use Sylius\Component\Core\Distributor\IntegerDistributorInterface;
use Sylius\Component\Core\Model\OrderInterface;
Expand Down Expand Up @@ -68,7 +69,6 @@ function it_applies_taxes_on_units_based_on_item_total_and_rate(
$items->getIterator()->willReturn(new \ArrayIterator([$orderItem->getWrappedObject()]));

$orderItem->getQuantity()->willReturn(2);

$orderItem->getVariant()->willReturn($productVariant);
$taxRateResolver->resolve($productVariant, ['zone' => $zone])->willReturn($taxRate);

Expand Down Expand Up @@ -144,13 +144,13 @@ function it_does_nothing_if_tax_rate_cannot_be_resolved(

$items->count()->willReturn(1);
$items->getIterator()->willReturn($iterator);

$iterator->rewind()->shouldBeCalled();
$iterator->valid()->willReturn(true, false)->shouldBeCalled();
$iterator->current()->willReturn($orderItem);
$iterator->next()->shouldBeCalled();

$orderItem->getQuantity()->willReturn(5);

$orderItem->getVariant()->willReturn($productVariant);
$taxRateResolver->resolve($productVariant, ['zone' => $zone])->willReturn(null);

Expand Down Expand Up @@ -195,10 +195,7 @@ function it_does_not_apply_taxes_with_amount_0(

$distributor->distribute(0, 2)->willReturn([0, 0]);

$adjustmentsFactory
->createWithData(AdjustmentInterface::TAX_ADJUSTMENT, 'Simple tax (0%)', 0, false)
->shouldNotBeCalled()
;
$adjustmentsFactory->createWithData(Argument::any())->shouldNotBeCalled();

$this->apply($order, $zone);
}
Expand Down
3 changes: 2 additions & 1 deletion spec/TaxesApplicator/OrderShipmentTaxesApplicatorSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function it_implements_an_order_shipment_taxes_applicator_interface(): void
$this->shouldImplement(OrderTaxesApplicatorInterface::class);
}

function it_applies_shipment_taxes_on_order_based_on_shipment_adjustments_promotions_and_rate(
function it_applies_shipment_taxes_on_order_based_on_shipment_adjustments(
CalculatorInterface $calculator,
AdjustmentFactoryInterface $adjustmentsFactory,
TaxRateResolverInterface $taxRateResolver,
Expand Down Expand Up @@ -137,6 +137,7 @@ function it_does_nothing_if_tax_rate_cannot_be_resolved(
): void {
$order->getShippingTotal()->willReturn(100);
$order->getShipments()->willReturn(new ArrayCollection([$shipment->getWrappedObject()]));

$shipment->getMethod()->willReturn($shippingMethod);

$taxRateResolver->resolve($shippingMethod, ['zone' => $zone])->willReturn(null);
Expand Down
2 changes: 1 addition & 1 deletion src/TaxesApplicator/OrderItemUnitsTaxesApplicator.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
* This class is not covered by the backward compatibility promise and it will be removed after update Sylius to 1.9.
* It is a duplication of a logic from Sylius to provide proper adjustments handling.
*/
class OrderItemUnitsTaxesApplicator implements OrderTaxesApplicatorInterface
final class OrderItemUnitsTaxesApplicator implements OrderTaxesApplicatorInterface
{
/** @var CalculatorInterface */
private $calculator;
Expand Down
2 changes: 1 addition & 1 deletion src/TaxesApplicator/OrderItemsTaxesApplicator.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
* This class is not covered by the backward compatibility promise and it will be removed after update Sylius to 1.9.
* It is a duplication of a logic from Sylius to provide proper adjustments handling.
*/
class OrderItemsTaxesApplicator implements OrderTaxesApplicatorInterface
final class OrderItemsTaxesApplicator implements OrderTaxesApplicatorInterface
{
/** @var CalculatorInterface */
private $calculator;
Expand Down
2 changes: 1 addition & 1 deletion src/TaxesApplicator/OrderShipmentTaxesApplicator.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
* This class is not covered by the backward compatibility promise and it will be removed after update Sylius to 1.9.
* It is a duplication of a logic from Sylius to provide proper adjustments handling.
*/
class OrderShipmentTaxesApplicator implements OrderTaxesApplicatorInterface
final class OrderShipmentTaxesApplicator implements OrderTaxesApplicatorInterface
{
/** @var CalculatorInterface */
private $calculator;
Expand Down

0 comments on commit 4336015

Please sign in to comment.