Skip to content

Commit

Permalink
add-previous-changes
Browse files Browse the repository at this point in the history
  • Loading branch information
SirDomin committed Jun 18, 2021
1 parent 90e2732 commit e18a91c
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 59 deletions.
24 changes: 6 additions & 18 deletions spec/Factory/ShopBillingDataFactorySpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,37 +14,25 @@
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
ShopBillingData $shopBillingData
): void {
$shopBillingDataFactory->createNew()->willReturn($shopBillingData);

$shopBillingData->setCompany('Needful Things')->shouldBeCalled();
$shopBillingData->setTaxId('000222')->shouldBeCalled();
$shopBillingData->setCountryCode('US')->shouldBeCalled();
Expand Down
18 changes: 0 additions & 18 deletions src/Entity/ShopBillingData.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@

namespace Sylius\RefundPlugin\Entity;

use Sylius\Component\Resource\Exception\UnsupportedMethodException;

/** final */
class ShopBillingData implements ShopBillingDataInterface
{
Expand All @@ -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;
Expand Down Expand Up @@ -117,9 +102,6 @@ public function setPostcode(?string $postcode): void
$this->postcode = $postcode;
}

/**
* @return mixed
*/
public function id()
{
return $this->id;
Expand Down
1 change: 1 addition & 0 deletions src/Entity/ShopBillingDataInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
18 changes: 4 additions & 14 deletions src/Factory/ShopBillingDataFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -42,7 +32,7 @@ public function createWithData(
?string $city,
?string $postcode
): ShopBillingDataInterface {
$shopBillingData = $this->createNew();
$shopBillingData = new ShopBillingData();

$shopBillingData->setCompany($company);
$shopBillingData->setTaxId($taxId);
Expand Down
1 change: 1 addition & 0 deletions src/Resources/config/app/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
9 changes: 0 additions & 9 deletions src/Resources/config/services/generators.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,6 @@
<argument>%sylius.refund.template.logo_file%</argument>
</service>

<service
id="Sylius\RefundPlugin\Factory\ShopBillingDataFactory"
decorates="sylius_refund.factory.shop_billing_data"
decoration-priority="256"
public="false"
>
<argument type="service" id="Sylius\RefundPlugin\Factory\ShopBillingDataFactory.inner" />
</service>

<service id="Sylius\RefundPlugin\Generator\CreditMemoPdfFileGenerator" alias="Sylius\RefundPlugin\Generator\CreditMemoPdfFileGeneratorInterface">
<deprecated>The "%alias_id%" service alias is deprecated and will be removed in RefundPlugin 1.0, use Sylius\RefundPlugin\Generator\CreditMemoPdfFileGeneratorInterface instead.</deprecated>
</service>
Expand Down

0 comments on commit e18a91c

Please sign in to comment.