|
17 | 17 | use Bazinga\GeocoderBundle\Tests\Functional\Fixtures\Entity\DummyWithGetter; |
18 | 18 | use Bazinga\GeocoderBundle\Tests\Functional\Fixtures\Entity\DummyWithInvalidGetter; |
19 | 19 | use Bazinga\GeocoderBundle\Tests\Functional\Fixtures\Entity\DummyWithProperty; |
| 20 | +use Bazinga\GeocoderBundle\Tests\Functional\Fixtures\Entity\DummyWithStringableGetter; |
| 21 | +use Bazinga\GeocoderBundle\Tests\Functional\Fixtures\Entity\StringableAddress; |
20 | 22 | use Doctrine\Bundle\DoctrineBundle\ConnectionFactory; |
21 | 23 | use Doctrine\Bundle\DoctrineBundle\DoctrineBundle; |
22 | 24 | use Doctrine\ORM\Configuration; |
@@ -177,6 +179,46 @@ public function testPersistForGetter(): void |
177 | 179 | self::assertNotEquals($clone->getLongitude(), $dummy->getLongitude()); |
178 | 180 | } |
179 | 181 |
|
| 182 | + public function testPersistForStringableGetter(): void |
| 183 | + { |
| 184 | + self::bootKernel(['config' => static function (TestKernel $kernel) { |
| 185 | + $kernel->addTestConfig(__DIR__.'/config/framework.yml'); |
| 186 | + |
| 187 | + if ($kernel::VERSION_ID >= 60000) { |
| 188 | + $kernel->addTestConfig(__DIR__.'/config/framework_sf6.yml'); |
| 189 | + } |
| 190 | + |
| 191 | + $kernel->addTestConfig(__DIR__.'/config/listener.yml'); |
| 192 | + $kernel->addTestConfig(__DIR__.'/config/listener_'.(PHP_VERSION_ID >= 80000 ? 'php8' : 'php7').'.yml'); |
| 193 | + }]); |
| 194 | + |
| 195 | + $container = self::getContainer(); |
| 196 | + $container->set('http_client', self::createHttpClientForBerlinQuery()); |
| 197 | + |
| 198 | + $em = $container->get('doctrine.orm.entity_manager'); |
| 199 | + |
| 200 | + $tool = new SchemaTool($em); |
| 201 | + $tool->createSchema($em->getMetadataFactory()->getAllMetadata()); |
| 202 | + |
| 203 | + $dummy = new DummyWithStringableGetter(); |
| 204 | + $dummy->setAddress(new StringableAddress('Berlin, Germany')); |
| 205 | + |
| 206 | + $em->persist($dummy); |
| 207 | + $em->flush(); |
| 208 | + |
| 209 | + self::assertNotNull($dummy->latitude); |
| 210 | + self::assertNotNull($dummy->longitude); |
| 211 | + |
| 212 | + $clone = clone $dummy; |
| 213 | + $dummy->setAddress(new StringableAddress('Paris, France')); |
| 214 | + |
| 215 | + $em->persist($dummy); |
| 216 | + $em->flush(); |
| 217 | + |
| 218 | + self::assertNotEquals($clone->latitude, $dummy->latitude); |
| 219 | + self::assertNotEquals($clone->longitude, $dummy->longitude); |
| 220 | + } |
| 221 | + |
180 | 222 | public function testPersistForInvalidGetter(): void |
181 | 223 | { |
182 | 224 | self::bootKernel(['config' => static function (TestKernel $kernel) { |
|
0 commit comments