1
|
|
|
<?php declare(strict_types=1); |
2
|
|
|
|
3
|
|
|
namespace EdmondsCommerce\DoctrineStaticMeta\Tests\Large\Entity\Fields\Traits\PrimaryKey; |
4
|
|
|
|
5
|
|
|
use EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\Generator\Field\IdTrait; |
6
|
|
|
use EdmondsCommerce\DoctrineStaticMeta\Entity\Fields\Interfaces\PrimaryKey\IdFieldInterface; |
7
|
|
|
use EdmondsCommerce\DoctrineStaticMeta\Entity\Fields\Traits\PrimaryKey\NonBinaryUuidFieldTrait; |
8
|
|
|
use EdmondsCommerce\DoctrineStaticMeta\Tests\Assets\AbstractTest; |
9
|
|
|
use Ramsey\Uuid\UuidInterface; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* Class UuidFieldTraitTest |
13
|
|
|
* |
14
|
|
|
* @package EdmondsCommerce\DoctrineStaticMeta\Entity\Fields\Traits\PrimaryKey |
15
|
|
|
* @SuppressWarnings(PHPMD.DepthOfInheritance) |
16
|
|
|
*/ |
17
|
|
|
class NonBinaryUuidFieldTraitTest extends IdFieldTraitTest |
18
|
|
|
{ |
19
|
|
|
public const WORK_DIR = AbstractTest::VAR_PATH . |
20
|
|
|
'/' . |
21
|
|
|
self::TEST_TYPE_LARGE . |
22
|
|
|
'/NonBinaryUuidFieldTraitTest/'; |
23
|
|
|
protected const TEST_FIELD_FQN = NonBinaryUuidFieldTrait::class; |
24
|
|
|
protected const TEST_FIELD_PROP = IdFieldInterface::PROP_ID; |
25
|
|
|
|
26
|
|
|
public function generateCode() |
27
|
|
|
{ |
28
|
|
|
$this->getEntityGenerator() |
29
|
|
|
->setPrimaryKeyType(IdTrait::NON_BINARY_UUID_TRAIT) |
30
|
|
|
->generateEntity(static::TEST_ENTITY_FQN_BASE . $this->entitySuffix); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @test |
35
|
|
|
* @large |
36
|
|
|
* @covers \EdmondsCommerce\DoctrineStaticMeta\Entity\Fields\Traits\PrimaryKey\UuidFieldTrait |
37
|
|
|
* @throws \ReflectionException |
38
|
|
|
*/ |
39
|
|
|
public function createEntityWithField(): void |
40
|
|
|
{ |
41
|
|
|
parent::createEntityWithField(); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @test |
46
|
|
|
* @large |
47
|
|
|
* @covers \EdmondsCommerce\DoctrineStaticMeta\Entity\Fields\Traits\PrimaryKey\UuidFieldTrait |
48
|
|
|
* @throws \EdmondsCommerce\DoctrineStaticMeta\Exception\DoctrineStaticMetaException |
49
|
|
|
* @throws \ReflectionException |
50
|
|
|
*/ |
51
|
|
|
public function createDatabaseSchema() |
52
|
|
|
{ |
53
|
|
|
parent::createDatabaseSchema(); // TODO: Change the autogenerated stub |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
protected function validateSavedEntity($entity) |
57
|
|
|
{ |
58
|
|
|
$id = $entity->getId(); |
59
|
|
|
self::assertNotEmpty($id); |
60
|
|
|
self::assertInstanceOf(UuidInterface::class, $id); |
61
|
|
|
} |
62
|
|
|
} |
63
|
|
|
|