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
|
|
|
* @large |
12
|
|
|
* @covers \EdmondsCommerce\DoctrineStaticMeta\Entity\Fields\Traits\String\BusinessIdentifierCodeFieldTrait |
13
|
|
|
* @covers \EdmondsCommerce\DoctrineStaticMeta\Entity\Fields\FakerData\String\BusinessIdentifierCodeFakerData |
14
|
|
|
*/ |
15
|
|
|
class IndexedAutoIncrementFieldTraitTest extends AbstractFieldTraitTest |
16
|
|
|
{ |
17
|
|
|
public const WORK_DIR = AbstractTest::VAR_PATH . '/' . self::TEST_TYPE_LARGE |
18
|
|
|
. '/IndexedAutoIncrementFieldTraitTest/'; |
19
|
|
|
protected const TEST_FIELD_FQN = IndexedAutoIncrementFieldTrait::class; |
20
|
|
|
protected const TEST_FIELD_PROP = IndexedAutoIncrementFieldInterface::PROP_INDEXED_AUTO_INCREMENT; |
21
|
|
|
protected const TEST_FIELD_DEFAULT = IndexedAutoIncrementFieldInterface::DEFAULT_INDEXED_AUTO_INCREMENT; |
22
|
|
|
protected const HAS_SETTER = false; |
23
|
|
|
protected const VALIDATES = false; |
24
|
|
|
|
25
|
|
|
public function setUp() |
26
|
|
|
{ |
27
|
|
|
parent::setup(); |
28
|
|
|
$this->createDatabase(); |
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
|
|
|
private function persistThreeEntities(): void |
53
|
|
|
{ |
54
|
|
|
$entity1 = $this->getEntity(); |
55
|
|
|
$entity2 = $this->getEntity(); |
56
|
|
|
$entity3 = $this->getEntity(); |
57
|
|
|
$this->getEntitySaver()->save($entity1); |
58
|
|
|
$this->getEntitySaver()->save($entity2); |
59
|
|
|
$this->getEntitySaver()->save($entity3); |
60
|
|
|
$this->getEntityManager()->getUnitOfWork()->clear(); |
61
|
|
|
} |
62
|
|
|
} |
63
|
|
|
|
This function has been deprecated. The supplier of the function has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.