|
1
|
|
|
<?php declare(strict_types=1); |
|
2
|
|
|
|
|
3
|
|
|
namespace EdmondsCommerce\DoctrineStaticMeta\Tests\Large\C\Entity\Embeddable\Traits\Geo; |
|
4
|
|
|
|
|
5
|
|
|
use EdmondsCommerce\DoctrineStaticMeta\Entity\Embeddable\Interfaces\Geo\HasAddressEmbeddableInterface; |
|
6
|
|
|
use EdmondsCommerce\DoctrineStaticMeta\Entity\Embeddable\Traits\Geo\HasAddressEmbeddableTrait; |
|
7
|
|
|
use EdmondsCommerce\DoctrineStaticMeta\Tests\Assets\AbstractLargeTest; |
|
8
|
|
|
|
|
9
|
|
|
class HasAddressEmbeddableTraitLargeTest extends AbstractLargeTest |
|
10
|
|
|
{ |
|
11
|
|
|
public const WORK_DIR = self::VAR_PATH . |
|
12
|
|
|
'/' . |
|
13
|
|
|
self::TEST_TYPE_LARGE . |
|
14
|
|
|
'/HasAddressEmbeddableTraitLargeTest'; |
|
15
|
|
|
private const TEST_ENTITY = self::TEST_PROJECT_ROOT_NAMESPACE . '\\Entities\\Place'; |
|
16
|
|
|
protected static $buildOnce = true; |
|
17
|
|
|
private $entityFqn; |
|
18
|
|
|
|
|
19
|
|
|
public function setup() |
|
20
|
|
|
{ |
|
21
|
|
|
parent::setUp(); |
|
22
|
|
|
if (false === self::$built) { |
|
23
|
|
|
$this->getEntityGenerator()->generateEntity(self::TEST_ENTITY); |
|
24
|
|
|
$this->getEntityEmbeddableSetter() |
|
25
|
|
|
->setEntityHasEmbeddable(self::TEST_ENTITY, HasAddressEmbeddableTrait::class); |
|
26
|
|
|
} |
|
27
|
|
|
$this->setupCopiedWorkDirAndCreateDatabase(); |
|
28
|
|
|
$this->recreateDtos(); |
|
29
|
|
|
$this->entityFqn = $this->getCopiedFqn(self::TEST_ENTITY); |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* @test |
|
34
|
|
|
* @large |
|
35
|
|
|
* @covers \EdmondsCommerce\DoctrineStaticMeta\Entity\Embeddable\Traits\Geo\HasAddressEmbeddableTrait |
|
36
|
|
|
*/ |
|
37
|
|
|
public function theEntityCanBeSavedAndLoadedWithCorrectValues(): void |
|
38
|
|
|
{ |
|
39
|
|
|
/** |
|
40
|
|
|
* @var HasAddressEmbeddableInterface $entity |
|
41
|
|
|
*/ |
|
42
|
|
|
$entity = $this->createEntity($this->entityFqn); |
|
43
|
|
|
$entity->getAddressEmbeddable() |
|
44
|
|
|
->setCity('the city') |
|
45
|
|
|
->setCountryCode('ABC') |
|
46
|
|
|
->setHouseName('foo') |
|
47
|
|
|
->setHouseNumber('345') |
|
48
|
|
|
->setPostalArea('cheese land') |
|
49
|
|
|
->setPostalCode('ABC 123') |
|
50
|
|
|
->setStreet('streety street'); |
|
51
|
|
|
|
|
52
|
|
|
$this->getEntitySaver()->save($entity); |
|
53
|
|
|
|
|
54
|
|
|
$loaded = $this->getRepositoryFactory() |
|
55
|
|
|
->getRepository($this->entityFqn) |
|
56
|
|
|
->findAll()[0]; |
|
57
|
|
|
self::assertSame($entity, $loaded); |
|
58
|
|
|
} |
|
59
|
|
|
} |
|
60
|
|
|
|