/** * @test * @todo We need different tests at least for two types of database. * * 1. mysql without timezone support. * * 2. a db with timezone support. * But since flow does not support multiple db endpoints this is a test just for mysql. * In case of mysql, Doctrine handles datetimetz fields simply the same way as datetime does (pure string with date and time but without tz) */ public function dateTimeTzIsPersistedAndIsReconstituted() { $this->markTestIncomplete('We need different tests at least for two types of database. 1. mysql without timezone support. 2. a db with timezone support.'); // Make sure running in specific mode independent from testing env settings ini_set('date.timezone', 'Arctic/Longyearbyen'); $dateTimeTz = new \DateTime('2008-11-16 19:03:30', new \DateTimeZone('UTC')); $extendedTypesEntity = new Fixtures\ExtendedTypesEntity(); $extendedTypesEntity->setDateTimeTz($dateTimeTz); $this->persistenceManager->add($extendedTypesEntity); $this->persistenceManager->persistAll(); $this->persistenceManager->clearState(); /** @var Fixtures\ExtendedTypesEntity $persistedExtendedTypesEntity */ $persistedExtendedTypesEntity = $this->extendedTypesEntityRepository->findAll()->getFirst(); // Restore test env timezone ini_restore('date.timezone'); $this->assertInstanceOf(Fixtures\ExtendedTypesEntity::class, $persistedExtendedTypesEntity); $this->assertInstanceOf('DateTime', $persistedExtendedTypesEntity->getDateTimeTz()); $this->assertNotEquals($dateTimeTz->getTimestamp(), $persistedExtendedTypesEntity->getDateTimeTz()->getTimestamp()); $this->assertEquals(ini_get('datetime.timezone'), $persistedExtendedTypesEntity->getDateTimeTz()->getTimezone()->getName()); }