ClassMetadataFactoryTest   A
last analyzed

Complexity

Total Complexity 15

Size/Duplication

Total Lines 372
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 190
dl 0
loc 372
rs 10
c 2
b 0
f 0
wmc 15

14 Methods

Rating   Name   Duplication   Size   Complexity  
A testGetMetadataForSingleClass() 0 32 1
A testQuoteMetadata() 0 61 1
A createTestFactory() 0 8 1
A createValidClassMetadata() 0 54 1
A testAcceptsEntityManagerInterfaceInstances() 0 11 1
A testInheritsIdGeneratorMappingFromEmbeddable() 0 10 1
A testRejectsEmbeddableWithoutValidClassName() 0 20 1
A createEntityManager() 0 16 2
A testNoDefaultDiscriminatorMapIsAssumed() 0 13 1
A testFallbackLoadingCausesEventTriggeringThatCanModifyFetchedMetadata() 0 26 1
A testHasGetMetadataNamespaceSeparatorIsNotNormalized() 0 16 1
A classesInInheritanceWithNoMapProvider() 0 5 1
A testIsTransient() 0 17 1
A testGetAllMetadataWorksWithBadConnection() 0 21 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\Tests\ORM\Mapping;
6
7
use Doctrine\Common\EventManager;
8
use Doctrine\DBAL\Connection;
9
use Doctrine\DBAL\Types\Type;
10
use Doctrine\ORM\Configuration;
11
use Doctrine\ORM\EntityManagerInterface;
12
use Doctrine\ORM\Event\OnClassMetadataNotFoundEventArgs;
13
use Doctrine\ORM\Events;
14
use Doctrine\ORM\Mapping;
15
use Doctrine\ORM\Mapping\ClassMetadata;
16
use Doctrine\ORM\Mapping\ClassMetadataFactory;
17
use Doctrine\ORM\Mapping\Driver\MappingDriver;
18
use Doctrine\ORM\Mapping\MappingException;
19
use Doctrine\ORM\Sequencing\Generator;
20
use Doctrine\Tests\Mocks\ConnectionMock;
21
use Doctrine\Tests\Mocks\DriverMock;
22
use Doctrine\Tests\Mocks\EntityManagerMock;
23
use Doctrine\Tests\Mocks\MetadataDriverMock;
24
use Doctrine\Tests\Models\CMS\CmsArticle;
25
use Doctrine\Tests\Models\CMS\CmsUser;
26
use Doctrine\Tests\Models\DDC4006\DDC4006User;
27
use Doctrine\Tests\Models\JoinedInheritanceType\AnotherChildClass;
28
use Doctrine\Tests\Models\JoinedInheritanceType\ChildClass;
29
use Doctrine\Tests\Models\JoinedInheritanceType\RootClass;
30
use Doctrine\Tests\Models\Quote;
31
use Doctrine\Tests\OrmTestCase;
32
use DoctrineGlobalArticle;
33
use Exception;
34
use InvalidArgumentException;
35
use stdClass;
36
use function reset;
37
use function sprintf;
38
39
class ClassMetadataFactoryTest extends OrmTestCase
40
{
41
    public function testGetMetadataForSingleClass() : void
42
    {
43
        $mockDriver    = new MetadataDriverMock();
44
        $entityManager = $this->createEntityManager($mockDriver);
45
46
        $conn         = $entityManager->getConnection();
47
        $mockPlatform = $conn->getDatabasePlatform();
48
        $mockPlatform->setPrefersSequences(true);
0 ignored issues
show
Bug introduced by
The method setPrefersSequences() does not exist on Doctrine\DBAL\Platforms\AbstractPlatform. It seems like you code against a sub-type of Doctrine\DBAL\Platforms\AbstractPlatform such as Doctrine\Tests\Mocks\DatabasePlatformMock. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

48
        $mockPlatform->/** @scrutinizer ignore-call */ 
49
                       setPrefersSequences(true);
Loading history...
49
        $mockPlatform->setPrefersIdentityColumns(false);
0 ignored issues
show
Bug introduced by
The method setPrefersIdentityColumns() does not exist on Doctrine\DBAL\Platforms\AbstractPlatform. It seems like you code against a sub-type of Doctrine\DBAL\Platforms\AbstractPlatform such as Doctrine\Tests\Mocks\DatabasePlatformMock. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

49
        $mockPlatform->/** @scrutinizer ignore-call */ 
50
                       setPrefersIdentityColumns(false);
Loading history...
50
51
        $cm1 = $this->createValidClassMetadata();
52
53
        // SUT
54
        $cmf = new ClassMetadataFactory();
55
        $cmf->setEntityManager($entityManager);
56
        $cmf->setMetadataFor($cm1->getClassName(), $cm1);
57
58
        // Prechecks
59
        self::assertCount(0, $cm1->getAncestorsIterator());
60
        self::assertEquals(Mapping\InheritanceType::NONE, $cm1->inheritanceType);
61
        self::assertEquals(Mapping\GeneratorType::SEQUENCE, $cm1->getProperty('id')->getValueGenerator()->getType());
0 ignored issues
show
Bug introduced by
The method getValueGenerator() does not exist on Doctrine\ORM\Mapping\Property. Did you maybe mean getValue()? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

61
        self::assertEquals(Mapping\GeneratorType::SEQUENCE, $cm1->getProperty('id')->/** @scrutinizer ignore-call */ getValueGenerator()->getType());

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.

Loading history...
62
        self::assertTrue($cm1->hasField('name'));
63
        self::assertCount(4, $cm1->getPropertiesIterator()); // 2 fields + 2 associations
64
        self::assertEquals('group', $cm1->table->getName());
65
66
        // Go
67
        $cmMap1 = $cmf->getMetadataFor($cm1->getClassName());
68
69
        self::assertSame($cm1, $cmMap1);
70
        self::assertEquals('group', $cmMap1->table->getName());
71
        self::assertCount(0, $cmMap1->getAncestorsIterator());
72
        self::assertTrue($cmMap1->hasField('name'));
73
    }
74
75
    public function testHasGetMetadataNamespaceSeparatorIsNotNormalized() : void
76
    {
77
        require_once __DIR__ . '/../../Models/Global/GlobalNamespaceModel.php';
78
79
        $metadataDriver = $this->createAnnotationDriver([__DIR__ . '/../../Models/Global/']);
80
81
        $entityManager = $this->createEntityManager($metadataDriver);
82
83
        $mf = $entityManager->getMetadataFactory();
84
85
        self::assertSame(
86
            $mf->getMetadataFor(DoctrineGlobalArticle::class),
87
            $mf->getMetadataFor('\\' . DoctrineGlobalArticle::class)
88
        );
89
        self::assertTrue($mf->hasMetadataFor(DoctrineGlobalArticle::class));
90
        self::assertTrue($mf->hasMetadataFor('\\' . DoctrineGlobalArticle::class));
91
    }
92
93
    /**
94
     * @group DDC-1512
95
     */
96
    public function testIsTransient() : void
97
    {
98
        $cmf    = new ClassMetadataFactory();
0 ignored issues
show
Unused Code introduced by
The assignment to $cmf is dead and can be removed.
Loading history...
99
        $driver = $this->createMock(MappingDriver::class);
100
        $driver->expects($this->at(0))
101
               ->method('isTransient')
102
               ->with($this->equalTo(CmsUser::class))
103
               ->will($this->returnValue(true));
104
        $driver->expects($this->at(1))
105
               ->method('isTransient')
106
               ->with($this->equalTo(CmsArticle::class))
107
               ->will($this->returnValue(false));
108
109
        $em = $this->createEntityManager($driver);
110
111
        self::assertTrue($em->getMetadataFactory()->isTransient(CmsUser::class));
112
        self::assertFalse($em->getMetadataFactory()->isTransient(CmsArticle::class));
113
    }
114
115
    /**
116
     * @dataProvider classesInInheritanceWithNoMapProvider()
117
     */
118
    public function testNoDefaultDiscriminatorMapIsAssumed(string $rootClassName, string $targetClassName) : void
119
    {
120
        $cmf    = new ClassMetadataFactory();
121
        $driver = $this->createAnnotationDriver([__DIR__ . '/../../Models/JoinedInheritanceType/']);
122
        $em     = $this->createEntityManager($driver);
123
        $cmf->setEntityManager($em);
124
125
        $this->expectException(MappingException::class);
126
        $this->expectExceptionMessage(
127
            sprintf("Entity class '%s' is using inheritance but no discriminator map was defined.", $rootClassName)
128
        );
129
130
        $cmf->getMetadataFor($targetClassName);
131
    }
132
133
    /**
134
     * @return string[]
135
     */
136
    public function classesInInheritanceWithNoMapProvider() : iterable
137
    {
138
        yield 'root entity' => [RootClass::class, RootClass::class];
0 ignored issues
show
Bug Best Practice introduced by
The expression yield 'root entity' => a...eType\RootClass::class) returns the type Generator which is incompatible with the documented return type string[].
Loading history...
139
        yield 'child entity' => [RootClass::class, ChildClass::class];
140
        yield 'another child entity' => [RootClass::class, AnotherChildClass::class];
141
    }
142
143
    public function testGetAllMetadataWorksWithBadConnection() : void
144
    {
145
        // DDC-3551
146
        $conn       = $this->createMock(Connection::class);
147
        $mockDriver = new MetadataDriverMock();
148
        $conn->expects($this->any())
149
            ->method('getEventManager')
150
            ->willReturn(new EventManager());
151
        $em = $this->createEntityManager($mockDriver, $conn);
152
153
        $conn->expects($this->any())
154
            ->method('getDatabasePlatform')
155
            ->will($this->throwException(new Exception('Exception thrown in test when calling getDatabasePlatform')));
156
157
        $cmf = new ClassMetadataFactory();
158
        $cmf->setEntityManager($em);
159
160
        // getting all the metadata should work, even if get DatabasePlatform blows up
161
        $metadata = $cmf->getAllMetadata();
162
        // this will just be an empty array - there was no error
163
        self::assertEquals([], $metadata);
164
    }
165
166
    protected function createEntityManager($metadataDriver, $conn = null)
167
    {
168
        $driverMock = new DriverMock();
169
        $config     = new Configuration();
170
171
        $config->setProxyDir(__DIR__ . '/../../Proxies');
172
        $config->setProxyNamespace('Doctrine\Tests\Proxies');
173
174
        if (! $conn) {
175
            $conn = new ConnectionMock([], $driverMock, $config, new EventManager());
176
        }
177
        $eventManager = $conn->getEventManager();
178
179
        $config->setMetadataDriverImpl($metadataDriver);
180
181
        return EntityManagerMock::create($conn, $config, $eventManager);
182
    }
183
184
    /**
185
     * @return ClassMetadataFactoryTestSubject
186
     */
187
    protected function createTestFactory()
188
    {
189
        $mockDriver    = new MetadataDriverMock();
190
        $entityManager = $this->createEntityManager($mockDriver);
191
        $cmf           = new ClassMetadataFactoryTestSubject();
192
        $cmf->setEntityManager($entityManager);
193
194
        return $cmf;
195
    }
196
197
    /**
198
     * @return ClassMetadata
199
     */
200
    protected function createValidClassMetadata()
201
    {
202
        $cm1 = new ClassMetadata(TestEntity1::class, null);
203
204
        $tableMetadata = new Mapping\TableMetadata();
205
        $tableMetadata->setName('group');
206
207
        $cm1->setTable($tableMetadata);
208
209
        // Add a mapped field
210
        $fieldMetadata = new Mapping\FieldMetadata('id');
211
212
        $fieldMetadata->setType(Type::getType('integer'));
213
        $fieldMetadata->setPrimaryKey(true);
214
        $fieldMetadata->setValueGenerator(new Mapping\ValueGeneratorMetadata(
215
            Mapping\GeneratorType::SEQUENCE,
216
            new Generator\SequenceGenerator('group_id_seq', 1)
217
        ));
218
219
        $cm1->addProperty($fieldMetadata);
220
221
        // Add a mapped field
222
        $fieldMetadata = new Mapping\FieldMetadata('name');
223
224
        $fieldMetadata->setType(Type::getType('string'));
225
226
        $cm1->addProperty($fieldMetadata);
227
228
        // and a mapped association
229
        $association = new Mapping\OneToOneAssociationMetadata('other');
230
231
        $association->setTargetEntity(TestEntity1::class);
232
        $association->setMappedBy('this');
233
234
        $cm1->addProperty($association);
235
236
        // and an association on the owning side
237
        $joinColumns = [];
238
239
        $joinColumn = new Mapping\JoinColumnMetadata();
240
241
        $joinColumn->setColumnName('other_id');
242
        $joinColumn->setReferencedColumnName('id');
243
244
        $joinColumns[] = $joinColumn;
245
246
        $association = new Mapping\OneToOneAssociationMetadata('association');
247
248
        $association->setJoinColumns($joinColumns);
249
        $association->setTargetEntity(TestEntity1::class);
250
251
        $cm1->addProperty($association);
252
253
        return $cm1;
254
    }
255
256
    /**
257
     * @group DDC-1845
258
     */
259
    public function testQuoteMetadata() : void
260
    {
261
        $cmf    = new ClassMetadataFactory();
262
        $driver = $this->createAnnotationDriver([__DIR__ . '/../../Models/Quote/']);
263
        $em     = $this->createEntityManager($driver);
264
        $cmf->setEntityManager($em);
265
266
        $userMetadata    = $cmf->getMetadataFor(Quote\User::class);
267
        $phoneMetadata   = $cmf->getMetadataFor(Quote\Phone::class);
268
        $groupMetadata   = $cmf->getMetadataFor(Quote\Group::class);
269
        $addressMetadata = $cmf->getMetadataFor(Quote\Address::class);
270
271
        // Phone Class Metadata
272
        self::assertNotNull($phoneMetadata->getProperty('number'));
273
        self::assertEquals('phone-number', $phoneMetadata->getProperty('number')->getColumnName());
0 ignored issues
show
Bug introduced by
The method getColumnName() does not exist on Doctrine\ORM\Mapping\Property. It seems like you code against a sub-type of Doctrine\ORM\Mapping\Property such as Doctrine\ORM\Mapping\FieldMetadata. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

273
        self::assertEquals('phone-number', $phoneMetadata->getProperty('number')->/** @scrutinizer ignore-call */ getColumnName());
Loading history...
274
275
        $user                = $phoneMetadata->getProperty('user');
276
        $userJoinColumns     = $user->getJoinColumns();
0 ignored issues
show
Bug introduced by
The method getJoinColumns() does not exist on Doctrine\ORM\Mapping\Property. It seems like you code against a sub-type of Doctrine\ORM\Mapping\Property such as Doctrine\ORM\Mapping\ToOneAssociationMetadata. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

276
        /** @scrutinizer ignore-call */ 
277
        $userJoinColumns     = $user->getJoinColumns();
Loading history...
277
        $phoneUserJoinColumn = reset($userJoinColumns);
278
279
        self::assertEquals('user-id', $phoneUserJoinColumn->getColumnName());
280
        self::assertEquals('user-id', $phoneUserJoinColumn->getReferencedColumnName());
281
282
        // Address Class Metadata
283
        self::assertNotNull($addressMetadata->getProperty('id'));
284
        self::assertNotNull($addressMetadata->getProperty('zip'));
285
        self::assertEquals('address-id', $addressMetadata->getProperty('id')->getColumnName());
286
        self::assertEquals('address-zip', $addressMetadata->getProperty('zip')->getColumnName());
287
288
        // User Class Metadata
289
        self::assertNotNull($userMetadata->getProperty('id'));
290
        self::assertNotNull($userMetadata->getProperty('name'));
291
        self::assertEquals('user-id', $userMetadata->getProperty('id')->getColumnName());
292
        self::assertEquals('user-name', $userMetadata->getProperty('name')->getColumnName());
293
294
        $group               = $groupMetadata->getProperty('parent');
295
        $groupJoinColumns    = $group->getJoinColumns();
296
        $groupUserJoinColumn = reset($groupJoinColumns);
297
298
        self::assertEquals('parent-id', $groupUserJoinColumn->getColumnName());
299
        self::assertEquals('group-id', $groupUserJoinColumn->getReferencedColumnName());
300
301
        $user                  = $addressMetadata->getProperty('user');
302
        $userJoinColumns       = $user->getJoinColumns();
303
        $addressUserJoinColumn = reset($userJoinColumns);
304
305
        self::assertEquals('user-id', $addressUserJoinColumn->getColumnName());
306
        self::assertEquals('user-id', $addressUserJoinColumn->getReferencedColumnName());
307
308
        $groups                       = $userMetadata->getProperty('groups');
309
        $groupsJoinTable              = $groups->getJoinTable();
0 ignored issues
show
Bug introduced by
The method getJoinTable() does not exist on Doctrine\ORM\Mapping\Property. It seems like you code against a sub-type of Doctrine\ORM\Mapping\Property such as Doctrine\ORM\Mapping\ManyToManyAssociationMetadata. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

309
        /** @scrutinizer ignore-call */ 
310
        $groupsJoinTable              = $groups->getJoinTable();
Loading history...
310
        $userGroupsJoinColumns        = $groupsJoinTable->getJoinColumns();
311
        $userGroupsJoinColumn         = reset($userGroupsJoinColumns);
312
        $userGroupsInverseJoinColumns = $groupsJoinTable->getInverseJoinColumns();
313
        $userGroupsInverseJoinColumn  = reset($userGroupsInverseJoinColumns);
314
315
        self::assertEquals('quote-users-groups', $groupsJoinTable->getName());
316
        self::assertEquals('user-id', $userGroupsJoinColumn->getColumnName());
317
        self::assertEquals('user-id', $userGroupsJoinColumn->getReferencedColumnName());
318
        self::assertEquals('group-id', $userGroupsInverseJoinColumn->getColumnName());
319
        self::assertEquals('group-id', $userGroupsInverseJoinColumn->getReferencedColumnName());
320
    }
321
322
    /**
323
     * @group DDC-3385
324
     * @group 1181
325
     * @group 385
326
     */
327
    public function testFallbackLoadingCausesEventTriggeringThatCanModifyFetchedMetadata() : void
328
    {
329
        /** @var ClassMetadata $metadata */
330
        $metadata     = $this->createMock(ClassMetadata::class);
331
        $cmf          = new ClassMetadataFactory();
332
        $mockDriver   = new MetadataDriverMock();
333
        $em           = $this->createEntityManager($mockDriver);
334
        $listener     = $this->getMockBuilder(stdClass::class)->setMethods(['onClassMetadataNotFound'])->getMock();
335
        $eventManager = $em->getEventManager();
336
337
        $cmf->setEntityManager($em);
338
339
        $listener
340
            ->expects($this->any())
341
            ->method('onClassMetadataNotFound')
342
            ->will($this->returnCallback(static function (OnClassMetadataNotFoundEventArgs $args) use ($metadata, $em) {
343
                self::assertNull($args->getFoundMetadata());
344
                self::assertSame('Foo', $args->getClassName());
345
                self::assertSame($em, $args->getObjectManager());
346
347
                $args->setFoundMetadata($metadata);
348
            }));
349
350
        $eventManager->addEventListener([Events::onClassMetadataNotFound], $listener);
351
352
        self::assertSame($metadata, $cmf->getMetadataFor('Foo'));
353
    }
354
355
    /**
356
     * @group DDC-3427
357
     */
358
    public function testAcceptsEntityManagerInterfaceInstances() : void
359
    {
360
        $classMetadataFactory = new ClassMetadataFactory();
361
362
        /** @var EntityManagerInterface $entityManager */
363
        $entityManager = $this->createMock(EntityManagerInterface::class);
364
365
        $classMetadataFactory->setEntityManager($entityManager);
366
367
        // not really the cleanest way to check it, but we won't add a getter to the CMF just for the sake of testing.
368
        self::assertAttributeSame($entityManager, 'em', $classMetadataFactory);
0 ignored issues
show
Deprecated Code introduced by
The function PHPUnit\Framework\Assert::assertAttributeSame() has been deprecated: https://github.com/sebastianbergmann/phpunit/issues/3338 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

368
        /** @scrutinizer ignore-deprecated */ self::assertAttributeSame($entityManager, 'em', $classMetadataFactory);

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.

Loading history...
369
    }
370
371
    /**
372
     * @group embedded
373
     * @group DDC-3305
374
     */
375
    public function testRejectsEmbeddableWithoutValidClassName() : void
376
    {
377
        $metadata = $this->createValidClassMetadata();
378
379
        $metadata->mapEmbedded(
380
            [
381
                'fieldName'    => 'embedded',
382
                'class'        => '',
383
                'columnPrefix' => false,
384
            ]
385
        );
386
387
        $cmf = $this->createTestFactory();
388
389
        $cmf->setMetadataForClass($metadata->getClassName(), $metadata);
390
391
        $this->expectException(MappingException::class);
392
        $this->expectExceptionMessage('The embed mapping \'embedded\' misses the \'class\' attribute.');
393
394
        $cmf->getMetadataFor($metadata->getClassName());
395
    }
396
397
    /**
398
     * @group embedded
399
     * @group DDC-4006
400
     */
401
    public function testInheritsIdGeneratorMappingFromEmbeddable() : void
402
    {
403
        $cmf    = new ClassMetadataFactory();
404
        $driver = $this->createAnnotationDriver([__DIR__ . '/../../Models/DDC4006/']);
405
        $em     = $this->createEntityManager($driver);
406
        $cmf->setEntityManager($em);
407
408
        $userMetadata = $cmf->getMetadataFor(DDC4006User::class);
409
410
        self::assertTrue($userMetadata->isIdGeneratorIdentity());
0 ignored issues
show
Bug introduced by
The method isIdGeneratorIdentity() does not exist on Doctrine\ORM\Mapping\ClassMetadata. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

410
        self::assertTrue($userMetadata->/** @scrutinizer ignore-call */ isIdGeneratorIdentity());

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.

Loading history...
411
    }
412
}
413
414
/* Test subject class with overridden factory method for mocking purposes */
415
class ClassMetadataFactoryTestSubject extends ClassMetadataFactory
416
{
417
    private $mockMetadata     = [];
418
    private $requestedClasses = [];
419
420
    protected function newClassMetadataInstance(
421
        string $className,
422
        ?Mapping\ClassMetadata $parent,
0 ignored issues
show
Unused Code introduced by
The parameter $parent is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

422
        /** @scrutinizer ignore-unused */ ?Mapping\ClassMetadata $parent,

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
423
        Mapping\ClassMetadataBuildingContext $metadataBuildingContext
0 ignored issues
show
Unused Code introduced by
The parameter $metadataBuildingContext is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

423
        /** @scrutinizer ignore-unused */ Mapping\ClassMetadataBuildingContext $metadataBuildingContext

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
424
    ) : ClassMetadata {
425
        $this->requestedClasses[] = $className;
426
427
        if (! isset($this->mockMetadata[$className])) {
428
            throw new InvalidArgumentException(sprintf('No mock metadata found for class %s.', $className));
429
        }
430
431
        return $this->mockMetadata[$className];
432
    }
433
434
    public function setMetadataForClass($className, $metadata)
435
    {
436
        $this->mockMetadata[$className] = $metadata;
437
    }
438
439
    public function getRequestedClasses()
440
    {
441
        return $this->requestedClasses;
442
    }
443
}
444
445
class TestEntity1
446
{
447
    private $id;
0 ignored issues
show
introduced by
The private property $id is not used, and could be removed.
Loading history...
448
    private $name;
0 ignored issues
show
introduced by
The private property $name is not used, and could be removed.
Loading history...
449
    private $other;
0 ignored issues
show
introduced by
The private property $other is not used, and could be removed.
Loading history...
450
    private $association;
0 ignored issues
show
introduced by
The private property $association is not used, and could be removed.
Loading history...
451
    private $embedded;
0 ignored issues
show
introduced by
The private property $embedded is not used, and could be removed.
Loading history...
452
}
453
454
class CustomIdGenerator implements Generator\Generator
455
{
456
    /**
457
     * {@inheritdoc}
458
     */
459
    public function generate(EntityManagerInterface $em, ?object $entity)
460
    {
461
    }
462
463
    /**
464
     * {@inheritdoc}
465
     */
466
    public function isPostInsertGenerator() : bool
467
    {
468
        return false;
469
    }
470
}
471