|
1
|
|
|
<?php declare(strict_types=1); |
|
2
|
|
|
|
|
3
|
|
|
namespace EdmondsCommerce\DoctrineStaticMeta\Tests\Large\C\Entity\Fields\Traits\Numeric; |
|
4
|
|
|
|
|
5
|
|
|
use EdmondsCommerce\DoctrineStaticMeta\Entity\Fields\Interfaces\Numeric\IndexedAutoIncrementFieldInterface; |
|
6
|
|
|
use EdmondsCommerce\DoctrineStaticMeta\Entity\Fields\Traits\Numeric\IndexedAutoIncrementFieldTrait; |
|
7
|
|
|
use EdmondsCommerce\DoctrineStaticMeta\Tests\Assets\AbstractTest; |
|
8
|
|
|
use EdmondsCommerce\DoctrineStaticMeta\Tests\Large\C\Entity\Fields\Traits\AbstractFieldTraitTest; |
|
9
|
|
|
|
|
10
|
|
|
/** |
|
11
|
|
|
* @covers \EdmondsCommerce\DoctrineStaticMeta\Entity\Fields\Traits\String\BusinessIdentifierCodeFieldTrait |
|
12
|
|
|
* @covers \EdmondsCommerce\DoctrineStaticMeta\Entity\Fields\FakerData\String\BusinessIdentifierCodeFakerData |
|
13
|
|
|
*/ |
|
14
|
|
|
class IndexedAutoIncrementFieldTraitTest extends AbstractFieldTraitTest |
|
15
|
|
|
{ |
|
16
|
|
|
public const WORK_DIR = AbstractTest::VAR_PATH . '/' . self::TEST_TYPE_LARGE |
|
17
|
|
|
. '/IndexedAutoIncrementFieldTraitTest/'; |
|
18
|
|
|
protected const TEST_FIELD_FQN = IndexedAutoIncrementFieldTrait::class; |
|
19
|
|
|
protected const TEST_FIELD_PROP = IndexedAutoIncrementFieldInterface::PROP_INDEXED_AUTO_INCREMENT; |
|
20
|
|
|
protected const TEST_FIELD_DEFAULT = IndexedAutoIncrementFieldInterface::DEFAULT_INDEXED_AUTO_INCREMENT; |
|
21
|
|
|
protected const HAS_SETTER = false; |
|
22
|
|
|
protected const VALIDATES = false; |
|
23
|
|
|
|
|
24
|
|
|
public function setUp() |
|
25
|
|
|
{ |
|
26
|
|
|
parent::setup(); |
|
27
|
|
|
$this->createDatabase(); |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* @test |
|
33
|
|
|
* @throws \Exception |
|
34
|
|
|
*/ |
|
35
|
|
|
public function createEntityWithField(): void |
|
36
|
|
|
{ |
|
37
|
|
|
$this->persistThreeEntities(); |
|
38
|
|
|
$loaded = $this->getRepositoryFactory()->getRepository($this->getEntityFqn())->findAll(); |
|
39
|
|
|
list($entity1, $entity2, $entity3) = $loaded; |
|
40
|
|
|
$getter = $this->getGetter($entity1); |
|
41
|
|
|
self::assertTrue(\method_exists($entity1, $getter)); |
|
42
|
|
|
$value1 = $entity1->$getter(); |
|
43
|
|
|
$value2 = $entity2->$getter(); |
|
44
|
|
|
$value3 = $entity3->$getter(); |
|
45
|
|
|
self::assertInternalType('int', $value1); |
|
46
|
|
|
self::assertInternalType('int', $value2); |
|
47
|
|
|
self::assertInternalType('int', $value3); |
|
48
|
|
|
self::assertTrue($value2 > $value1); |
|
49
|
|
|
self::assertTrue($value3 > $value2); |
|
50
|
|
|
|
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
private function persistThreeEntities(): void |
|
54
|
|
|
{ |
|
55
|
|
|
$entity1 = $this->getEntity(); |
|
56
|
|
|
$entity2 = $this->getEntity(); |
|
57
|
|
|
$entity3 = $this->getEntity(); |
|
58
|
|
|
$this->getEntitySaver()->save($entity1); |
|
59
|
|
|
$this->getEntitySaver()->save($entity2); |
|
60
|
|
|
$this->getEntitySaver()->save($entity3); |
|
61
|
|
|
$this->getEntityManager()->getUnitOfWork()->clear(); |
|
62
|
|
|
} |
|
63
|
|
|
} |
|
64
|
|
|
|