44
55namespace Doctrine \Tests \ORM \Functional ;
66
7+ use Doctrine \ORM \Id \AssignedGenerator ;
78use Doctrine \ORM \Mapping \ClassMetadata ;
89use Doctrine \ORM \Mapping \ClassMetadataInfo ;
910use Doctrine \Tests \Models \Cache \Country ;
@@ -62,6 +63,24 @@ private function setupCountryModel(int $cacheUsage): void
6263 $ metadata ->enableCache (['usage ' => $ cacheUsage ]);
6364 }
6465
66+ private function loadFixturesCountriesWithoutPostInsertIdentifier (): void
67+ {
68+ $ metadata = $ this ->_em ->getClassMetaData (Country::class);
69+ $ metadata ->setIdGenerator (new AssignedGenerator ());
70+
71+ $ c1 = new Country ('Brazil ' );
72+ $ c1 ->setId (10 );
73+ $ c2 = new Country ('Germany ' );
74+ $ c2 ->setId (20 );
75+
76+ $ this ->countries [] = $ c1 ;
77+ $ this ->countries [] = $ c2 ;
78+
79+ $ this ->_em ->persist ($ c1 );
80+ $ this ->_em ->persist ($ c2 );
81+ $ this ->_em ->flush ();
82+ }
83+
6584 /** @param 'INSERT'|'UPDATE'|'DELETE' $type */
6685 private function assertQueryCountByType (string $ type , int $ expectedCount ): void
6786 {
@@ -77,7 +96,7 @@ private function assertQueryCountByType(string $type, int $expectedCount): void
7796 *
7897 * @dataProvider cacheUsageProvider
7998 */
80- public function testInsert (int $ cacheUsage ): void
99+ public function testInsertWithPostInsertIdentifier (int $ cacheUsage ): void
81100 {
82101 $ this ->setupCountryModel ($ cacheUsage );
83102
@@ -89,6 +108,23 @@ public function testInsert(int $cacheUsage): void
89108 self ::assertQueryCountByType ('INSERT ' , 2 );
90109 }
91110
111+ /**
112+ /* @param SupportedCacheUsage $cacheUsage
113+ *
114+ * @dataProvider cacheUsageProvider
115+ */
116+ public function testInsertWithoutPostInsertIdentifier (int $ cacheUsage ): void
117+ {
118+ $ this ->setupCountryModel ($ cacheUsage );
119+
120+ self ::assertQueryCountByType ('INSERT ' , 0 );
121+
122+ $ this ->loadFixturesCountriesWithoutPostInsertIdentifier ();
123+
124+ self ::assertCount (2 , $ this ->countries );
125+ self ::assertQueryCountByType ('INSERT ' , 2 );
126+ }
127+
92128 /**
93129 /* @param SupportedCacheUsage $cacheUsage
94130 *
0 commit comments