diff --git a/src/Entity/Location.php b/src/Entity/Location.php new file mode 100644 index 0000000..892f081 --- /dev/null +++ b/src/Entity/Location.php @@ -0,0 +1,141 @@ +id; + } + + public function getName(): ?string + { + return $this->name; + } + + public function setName(string $name): self + { + $this->name = $name; + + return $this; + } + + public function getStreet(): ?string + { + return $this->street; + } + + public function setStreet(string $street): self + { + $this->street = $street; + + return $this; + } + + public function getNumber(): ?string + { + return $this->number; + } + + public function setNumber(string $number): self + { + $this->number = $number; + + return $this; + } + + public function getPostalCode(): ?string + { + return $this->postalCode; + } + + public function setPostalCode(string $postalCode): self + { + $this->postalCode = $postalCode; + + return $this; + } + + public function getCity(): ?string + { + return $this->city; + } + + public function setCity(string $city): self + { + $this->city = $city; + + return $this; + } + + public function getCountryCode(): ?string + { + return $this->countryCode; + } + + public function setCountryCode(string $countryCode): self + { + $this->countryCode = $countryCode; + + return $this; + } +} diff --git a/src/Repository/LocationRepository.php b/src/Repository/LocationRepository.php new file mode 100644 index 0000000..8c52ba6 --- /dev/null +++ b/src/Repository/LocationRepository.php @@ -0,0 +1,34 @@ + + */ +class LocationRepository extends ServiceEntityRepository +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, Location::class); + } + + public function create(): Location + { + $location = new Location(); + + $this->getEntityManager()->persist($location); + + return $location; + } +} diff --git a/tests/Unit/Entity/LocationTest.php b/tests/Unit/Entity/LocationTest.php new file mode 100644 index 0000000..6a58a1d --- /dev/null +++ b/tests/Unit/Entity/LocationTest.php @@ -0,0 +1,69 @@ +location = new Location(); + } + + public function testName(): void + { + $this->assertNull($this->location->getName()); + $this->assertSame($this->location, $this->location->setName('Sulu GmbH')); + $this->assertNotNull($this->location->getName()); + $this->assertSame('Sulu GmbH', $this->location->getName()); + } + + public function testStreet(): void + { + $this->assertNull($this->location->getStreet()); + $this->assertSame($this->location, $this->location->setStreet('Teststreet')); + $this->assertNotNull($this->location->getStreet()); + $this->assertSame('Teststreet', $this->location->getStreet()); + } + + public function testNumber(): void + { + $this->assertNull($this->location->getNumber()); + $this->assertSame($this->location, $this->location->setNumber('42')); + $this->assertNotNull($this->location->getNumber()); + $this->assertSame('42', $this->location->getNumber()); + } + + public function testPostalCode(): void + { + $this->assertNull($this->location->getPostalCode()); + $this->assertSame($this->location, $this->location->setPostalCode('6850')); + $this->assertNotNull($this->location->getPostalCode()); + $this->assertSame('6850', $this->location->getPostalCode()); + } + + public function testCity(): void + { + $this->assertNull($this->location->getCity()); + $this->assertSame($this->location, $this->location->setCity('Dornbirn')); + $this->assertNotNull($this->location->getCity()); + $this->assertSame('Dornbirn', $this->location->getCity()); + } + + public function testCountryCode(): void + { + $this->assertNull($this->location->getCountryCode()); + $this->assertSame($this->location, $this->location->setCountryCode('AT')); + $this->assertNotNull($this->location->getCountryCode()); + $this->assertSame('AT', $this->location->getCountryCode()); + } +}