diff --git a/src/Entity/Customer.php b/src/Entity/Customer.php index 7cc62169..d6b759b3 100644 --- a/src/Entity/Customer.php +++ b/src/Entity/Customer.php @@ -152,6 +152,7 @@ class Customer implements EntityWithMetaFields * * @ORM\Column(name="country", type="string", length=2, nullable=false) * @Assert\NotBlank() + * @Assert\Country() * @Assert\Length(max=2) */ private $country; @@ -165,6 +166,7 @@ class Customer implements EntityWithMetaFields * * @ORM\Column(name="currency", type="string", length=3, nullable=false) * @Assert\NotBlank() + * @Assert\Currency() * @Assert\Length(max=3) */ private $currency = self::DEFAULT_CURRENCY; @@ -428,7 +430,7 @@ class Customer implements EntityWithMetaFields return $this->address; } - public function setCountry(string $country): Customer + public function setCountry(?string $country): Customer { $this->country = $country; @@ -440,14 +442,14 @@ class Customer implements EntityWithMetaFields return $this->country; } - public function setCurrency(string $currency): Customer + public function setCurrency(?string $currency): Customer { $this->currency = $currency; return $this; } - public function getCurrency(): string + public function getCurrency(): ?string { return $this->currency; } diff --git a/tests/Entity/CustomerTest.php b/tests/Entity/CustomerTest.php index 6cd9732b..104fb6cc 100644 --- a/tests/Entity/CustomerTest.php +++ b/tests/Entity/CustomerTest.php @@ -109,6 +109,12 @@ class CustomerTest extends TestCase self::assertInstanceOf(Customer::class, $sut->setVatId('ID 1234567890')); self::assertEquals('ID 1234567890', $sut->getVatId()); + + self::assertInstanceOf(Customer::class, $sut->setCountry(null)); + self::assertNull($sut->getCountry()); + + self::assertInstanceOf(Customer::class, $sut->setCurrency(null)); + self::assertNull($sut->getCurrency()); } public function testMetaFields()