-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
aa37348
commit 7dc36da
Showing
3 changed files
with
244 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Entity; | ||
|
||
use Doctrine\ORM\Mapping as ORM; | ||
|
||
/** | ||
* @ORM\Entity(repositoryClass="App\Repository\LocationRepository") | ||
*/ | ||
class Location | ||
{ | ||
/** | ||
* @var int|null | ||
* | ||
* @ORM\Id() | ||
* @ORM\GeneratedValue() | ||
* @ORM\Column(type="integer") | ||
*/ | ||
private $id; | ||
|
||
/** | ||
* @var string | ||
* | ||
* @ORM\Column(type="string", length=255) | ||
*/ | ||
private $name; | ||
|
||
/** | ||
* @var string | ||
* | ||
* @ORM\Column(type="string", length=255) | ||
*/ | ||
private $street; | ||
|
||
/** | ||
* @var string | ||
* | ||
* @ORM\Column(type="string", length=255) | ||
*/ | ||
private $number; | ||
|
||
/** | ||
* @var string | ||
* | ||
* @ORM\Column(type="string", length=255) | ||
*/ | ||
private $postalCode; | ||
|
||
/** | ||
* @var string | ||
* | ||
* @ORM\Column(type="string", length=255) | ||
*/ | ||
private $city; | ||
|
||
/** | ||
* @var string | ||
* | ||
* @ORM\Column(type="string", length=255) | ||
*/ | ||
private $countryCode; | ||
|
||
public function getId(): ?int | ||
{ | ||
return $this->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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Repository; | ||
|
||
use App\Entity\Location; | ||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; | ||
use Doctrine\Common\Persistence\ManagerRegistry; | ||
|
||
/** | ||
* @method Location|null find($id, $lockMode = null, $lockVersion = null) | ||
* @method Location|null findOneBy(array $criteria, array $orderBy = null) | ||
* @method Location[] findAll() | ||
* @method Location[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) | ||
* | ||
* @extends ServiceEntityRepository<Location> | ||
*/ | ||
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Tests\Unit\Entity; | ||
|
||
use App\Entity\Location; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class LocationTest extends TestCase | ||
{ | ||
/** | ||
* @var Location | ||
*/ | ||
private $location; | ||
|
||
public function setUp(): void | ||
{ | ||
$this->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()); | ||
} | ||
} |