1
|
|
|
<?php declare(strict_types=1); |
2
|
|
|
|
3
|
|
|
namespace EdmondsCommerce\DoctrineStaticMeta\Tests\Large\Entity\Traits; |
4
|
|
|
|
5
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
6
|
|
|
use EdmondsCommerce\DoctrineStaticMeta\Entity\DataTransferObjects\AbstractEntityUpdateDto; |
7
|
|
|
use EdmondsCommerce\DoctrineStaticMeta\Entity\Savers\EntitySaverInterface; |
8
|
|
|
use EdmondsCommerce\DoctrineStaticMeta\Exception\DoctrineStaticMetaException; |
9
|
|
|
use EdmondsCommerce\DoctrineStaticMeta\Tests\Assets\AbstractLargeTest; |
10
|
|
|
use EdmondsCommerce\DoctrineStaticMeta\Tests\Assets\TestCodeGenerator; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* @large |
14
|
|
|
*/ |
15
|
|
|
class ImplementNotifyChangeTrackingPolicyTest extends AbstractLargeTest |
16
|
|
|
{ |
17
|
|
|
public const WORK_DIR = self::VAR_PATH . |
18
|
|
|
'/' . |
19
|
|
|
self::TEST_TYPE_LARGE . |
20
|
|
|
'/ImplementNotifyChangeTrackingPolicyTest'; |
21
|
|
|
private const ENTITY_FQN = self::TEST_ENTITIES_ROOT_NAMESPACE . TestCodeGenerator::TEST_ENTITY_PERSON; |
22
|
|
|
protected static $buildOnce = true; |
23
|
|
|
private $entity; |
24
|
|
|
/** |
25
|
|
|
* @var string |
26
|
|
|
*/ |
27
|
|
|
private $entityFqn; |
28
|
|
|
/** |
29
|
|
|
* @var EntitySaverInterface |
30
|
|
|
*/ |
31
|
|
|
private $saver; |
32
|
|
|
/** |
33
|
|
|
* @var \EdmondsCommerce\DoctrineStaticMeta\Entity\Testing\EntityGenerator\TestEntityGenerator |
34
|
|
|
*/ |
35
|
|
|
private $testEntityGenerator; |
36
|
|
|
|
37
|
|
|
public function setup() |
38
|
|
|
{ |
39
|
|
|
parent::setUp(); |
40
|
|
|
if (false === self::$built) { |
41
|
|
|
$this->getTestCodeGenerator() |
42
|
|
|
->copyTo(self::WORK_DIR); |
43
|
|
|
self::$built = true; |
44
|
|
|
} |
45
|
|
|
$this->setupCopiedWorkDirAndCreateDatabase(); |
46
|
|
|
$this->entityFqn = $this->getCopiedFqn(self::ENTITY_FQN); |
47
|
|
|
$this->saver = $this->getEntitySaver(); |
48
|
|
|
$this->testEntityGenerator = $this->getTestEntityGeneratorFactory() |
49
|
|
|
->createForEntityFqn($this->entityFqn); |
50
|
|
|
$this->entity = $this->testEntityGenerator->generateEntity(); |
51
|
|
|
$this->testEntityGenerator->addAssociationEntities($this->entity); |
52
|
|
|
$this->saver->save($this->entity); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @test |
57
|
|
|
* @throws DoctrineStaticMetaException |
58
|
|
|
* @throws \ReflectionException |
59
|
|
|
*/ |
60
|
|
|
public function youCanUpdateWithAnEmptyCollection(): void |
61
|
|
|
{ |
62
|
|
|
$dto = new class($this->entityFqn, $this->entity->getId()) extends AbstractEntityUpdateDto |
63
|
|
|
{ |
64
|
|
|
public function getAttributesEmails(): ArrayCollection |
65
|
|
|
{ |
66
|
|
|
return new ArrayCollection(); |
67
|
|
|
} |
68
|
|
|
}; |
69
|
|
|
$this->entity->update($dto); |
70
|
|
|
$this->saver->save($this->entity); |
71
|
|
|
$this->getEntityManager()->clear(); |
72
|
|
|
$loaded = $this->getRepositoryFactory()->getRepository($this->entityFqn)->find($this->entity->getId()); |
73
|
|
|
$expected = 0; |
74
|
|
|
$actual = $loaded->getAttributesEmails()->count(); |
|
|
|
|
75
|
|
|
self::assertSame($expected, $actual); |
76
|
|
|
} |
77
|
|
|
} |
78
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.