File tree 3 files changed +73
-0
lines changed
3 files changed +73
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ declare (strict_types=1 );
4
+
5
+ namespace Doctrine \Tests \Models \ValueGenerators ;
6
+
7
+ use Doctrine \ORM \Annotation as ORM ;
8
+
9
+ /**
10
+ * @ORM\Entity
11
+ * @ORM\Table(name="vg_non_identifier_generators")
12
+ */
13
+ class NonIdentifierGenerators
14
+ {
15
+ /**
16
+ * @ORM\Column(type="integer")
17
+ * @ORM\Id
18
+ * @ORM\GeneratedValue("AUTO")
19
+ * @var int|null
20
+ */
21
+ private $ id ;
22
+
23
+ /**
24
+ * @ORM\Column(type="string")
25
+ * @ORM\GeneratedValue(strategy="CUSTOM")
26
+ * @ORM\CustomIdGenerator("Doctrine\Tests\Models\ValueGenerators\FooGenerator")
27
+ * @var string|null
28
+ */
29
+ private $ foo ;
30
+
31
+ /**
32
+ * @ORM\Column(type="string")
33
+ * @ORM\GeneratedValue(strategy="CUSTOM")
34
+ * @ORM\CustomIdGenerator("Doctrine\Tests\Models\ValueGenerators\BarGenerator")
35
+ * @var string|null
36
+ */
37
+ private $ bar ;
38
+
39
+ public function getId () : ?int
40
+ {
41
+ return $ this ->id ;
42
+ }
43
+
44
+ public function getFoo () : ?string
45
+ {
46
+ return $ this ->foo ;
47
+ }
48
+
49
+ public function getBar () : ?string
50
+ {
51
+ return $ this ->bar ;
52
+ }
53
+ }
Original file line number Diff line number Diff line change 6
6
use Doctrine \Tests \Models \ValueGenerators \BarGenerator ;
7
7
use Doctrine \Tests \Models \ValueGenerators \CompositeGeneratedIdentifier ;
8
8
use Doctrine \Tests \Models \ValueGenerators \FooGenerator ;
9
+ use Doctrine \Tests \Models \ValueGenerators \NonIdentifierGenerators ;
9
10
use Doctrine \Tests \OrmFunctionalTestCase ;
10
11
11
12
class ValueGeneratorsTest extends OrmFunctionalTestCase
@@ -34,4 +35,21 @@ public function testCompositeIdentifierWithMultipleGenerators() : void
34
35
);
35
36
self ::assertNotNull ($ entity );
36
37
}
38
+
39
+ public function testNonIdentifierGenerators () : void
40
+ {
41
+ $ entity = new NonIdentifierGenerators ();
42
+
43
+ $ this ->em ->persist ($ entity );
44
+ $ this ->em ->flush ();
45
+
46
+ self ::assertNotNull ($ entity ->getId ());
47
+ self ::assertSame (FooGenerator::VALUE , $ entity ->getFoo ());
48
+ self ::assertSame (BarGenerator::VALUE , $ entity ->getBar ());
49
+
50
+ $ this ->em ->clear ();
51
+
52
+ $ entity = $ this ->getEntityManager ()->find (NonIdentifierGenerators::class, $ entity ->getId ());
53
+ self ::assertNotNull ($ entity );
54
+ }
37
55
}
Original file line number Diff line number Diff line change @@ -317,6 +317,7 @@ abstract class OrmFunctionalTestCase extends OrmTestCase
317
317
],
318
318
'valueGenerators ' => [
319
319
Models \ValueGenerators \CompositeGeneratedIdentifier::class,
320
+ Models \ValueGenerators \NonIdentifierGenerators::class,
320
321
],
321
322
];
322
323
@@ -605,6 +606,7 @@ protected function tearDown()
605
606
606
607
if (isset ($ this ->usedModelSets ['value_generators ' ])) {
607
608
$ conn ->executeUpdate ('DELETE FROM vg_composite_generated_identifier ' );
609
+ $ conn ->executeUpdate ('DELETE FROM vg_non_identifier_generators ' );
608
610
}
609
611
610
612
$ this ->em ->clear ();
You can’t perform that action at this time.
0 commit comments