From d9d84fa08c7723526028151d8e29c289d00c2f88 Mon Sep 17 00:00:00 2001 From: SirDomin Date: Fri, 18 Jun 2021 13:14:00 +0200 Subject: [PATCH] add-previous-changes --- spec/Factory/ShopBillingDataFactorySpec.php | 40 +++++++------------- src/Entity/ShopBillingData.php | 18 --------- src/Entity/ShopBillingDataInterface.php | 1 + src/Factory/ShopBillingDataFactory.php | 18 ++------- src/Resources/config/app/config.yml | 1 + src/Resources/config/services/generators.xml | 9 ----- 6 files changed, 20 insertions(+), 67 deletions(-) diff --git a/spec/Factory/ShopBillingDataFactorySpec.php b/spec/Factory/ShopBillingDataFactorySpec.php index 507d681c5..341b841fd 100644 --- a/spec/Factory/ShopBillingDataFactorySpec.php +++ b/spec/Factory/ShopBillingDataFactorySpec.php @@ -14,43 +14,31 @@ namespace spec\Sylius\RefundPlugin\Factory; use PhpSpec\ObjectBehavior; -use Sylius\Component\Resource\Factory\FactoryInterface; -use Sylius\RefundPlugin\Entity\ShopBillingDataInterface; +use Sylius\Component\Resource\Exception\UnsupportedMethodException; +use Sylius\RefundPlugin\Entity\ShopBillingData; use Sylius\RefundPlugin\Factory\ShopBillingDataFactoryInterface; class ShopBillingDataFactorySpec extends ObjectBehavior { - public function let(FactoryInterface $shopBillingDataFactory): void - { - $this->beConstructedWith($shopBillingDataFactory); - } - public function it_implements_shop_billing_data_factory_interface(): void { $this->shouldImplement(ShopBillingDataFactoryInterface::class); } - public function it_creates_new_shop_billing_data( - FactoryInterface $shopBillingDataFactory, - ShopBillingDataInterface $shopBillingData - ): void { - $shopBillingDataFactory->createNew()->willReturn($shopBillingData); - - $this->createNew()->shouldReturn($shopBillingData); + public function it_doesnt_support_create_new_method(): void + { + $this->shouldThrow(UnsupportedMethodException::class)->during('createNew'); } - public function it_creates_new_shop_billing_data_with_data( - ShopBillingDataInterface $shopBillingData, - FactoryInterface $shopBillingDataFactory - ): void { - $shopBillingDataFactory->createNew()->willReturn($shopBillingData); - - $shopBillingData->setCompany('Needful Things')->shouldBeCalled(); - $shopBillingData->setTaxId('000222')->shouldBeCalled(); - $shopBillingData->setCountryCode('US')->shouldBeCalled(); - $shopBillingData->setStreet('Main St. 123')->shouldBeCalled(); - $shopBillingData->setCity('Los Angeles')->shouldBeCalled(); - $shopBillingData->setPostcode('90001')->shouldBeCalled(); + public function it_creates_new_shop_billing_data_with_data(): void { + $shopBillingData = new ShopBillingData(); + + $shopBillingData->setCompany('Needful Things'); + $shopBillingData->setTaxId('000222'); + $shopBillingData->setCountryCode('US'); + $shopBillingData->setStreet('Main St. 123'); + $shopBillingData->setCity('Los Angeles'); + $shopBillingData->setPostcode('90001'); $this ->createWithData('Needful Things', '000222', 'US', 'Main St. 123', 'Los Angeles', '90001') diff --git a/src/Entity/ShopBillingData.php b/src/Entity/ShopBillingData.php index 590d33454..66780c100 100644 --- a/src/Entity/ShopBillingData.php +++ b/src/Entity/ShopBillingData.php @@ -13,8 +13,6 @@ namespace Sylius\RefundPlugin\Entity; -use Sylius\Component\Resource\Exception\UnsupportedMethodException; - /** final */ class ShopBillingData implements ShopBillingDataInterface { @@ -39,19 +37,6 @@ class ShopBillingData implements ShopBillingDataInterface /** @var string|null */ protected $postcode; - public function __construct( - ?string $company, - ?string $taxId, - ?string $countryCode, - ?string $street, - ?string $city, - ?string $postcode - ) { - throw new UnsupportedMethodException('construct'); - } - /** - * @return mixed - */ public function getId() { return $this->id; @@ -117,9 +102,6 @@ public function setPostcode(?string $postcode): void $this->postcode = $postcode; } - /** - * @return mixed - */ public function id() { return $this->id; diff --git a/src/Entity/ShopBillingDataInterface.php b/src/Entity/ShopBillingDataInterface.php index 7674805b4..8db67ce18 100644 --- a/src/Entity/ShopBillingDataInterface.php +++ b/src/Entity/ShopBillingDataInterface.php @@ -48,6 +48,7 @@ public function setPostcode(?string $postcode): void; /** * @return mixed + * * @deprecated this function is deprecated and will be removed in v1.0.0. Use CustomerBillingDataInterface::getId() instead * @see CustomerBillingDataInterface::getId */ diff --git a/src/Factory/ShopBillingDataFactory.php b/src/Factory/ShopBillingDataFactory.php index 9cee2db8b..3e40113b0 100644 --- a/src/Factory/ShopBillingDataFactory.php +++ b/src/Factory/ShopBillingDataFactory.php @@ -13,25 +13,15 @@ namespace Sylius\RefundPlugin\Factory; -use Sylius\Component\Resource\Factory\FactoryInterface; +use Sylius\Component\Resource\Exception\UnsupportedMethodException; +use Sylius\RefundPlugin\Entity\ShopBillingData; use Sylius\RefundPlugin\Entity\ShopBillingDataInterface; final class ShopBillingDataFactory implements ShopBillingDataFactoryInterface { - /** @var FactoryInterface */ - private $shopBillingDataFactory; - - public function __construct(FactoryInterface $shopBillingDataFactory) - { - $this->shopBillingDataFactory = $shopBillingDataFactory; - } - public function createNew(): ShopBillingDataInterface { - /** @var ShopBillingDataInterface $shopBillingData */ - $shopBillingData = $this->shopBillingDataFactory->createNew(); - - return $shopBillingData; + throw new UnsupportedMethodException('This object is not default constructable.'); } public function createWithData( @@ -42,7 +32,7 @@ public function createWithData( ?string $city, ?string $postcode ): ShopBillingDataInterface { - $shopBillingData = $this->createNew(); + $shopBillingData = new ShopBillingData(); $shopBillingData->setCompany($company); $shopBillingData->setTaxId($taxId); diff --git a/src/Resources/config/app/config.yml b/src/Resources/config/app/config.yml index 4875cddd1..3705ace1d 100644 --- a/src/Resources/config/app/config.yml +++ b/src/Resources/config/app/config.yml @@ -25,6 +25,7 @@ sylius_resource: sylius_refund.shop_billing_data: classes: model: Sylius\RefundPlugin\Entity\ShopBillingData + factory: Sylius\RefundPlugin\Factory\ShopBillingDataFactory sylius_mailer: emails: diff --git a/src/Resources/config/services/generators.xml b/src/Resources/config/services/generators.xml index 4743ea633..8c3dacbc4 100644 --- a/src/Resources/config/services/generators.xml +++ b/src/Resources/config/services/generators.xml @@ -38,15 +38,6 @@ %sylius.refund.template.logo_file% - - - - The "%alias_id%" service alias is deprecated and will be removed in RefundPlugin 1.0, use Sylius\RefundPlugin\Generator\CreditMemoPdfFileGeneratorInterface instead.