@@ -345,4 +345,93 @@ public static function provideEscapeIdentifier(): iterable
345345 'with dots ' => ['com.sitedb.web ' , '"com.sitedb.web" ' ],
346346 ];
347347 }
348+
349+ public function testConvertTimezoneToOffsetWithOffset (): void
350+ {
351+ $ db = new MockConnection ($ this ->options );
352+
353+ // Offset strings should be returned as-is
354+ $ result = $ this ->getPrivateMethodInvoker ($ db , 'convertTimezoneToOffset ' )('+05:30 ' );
355+ $ this ->assertSame ('+05:30 ' , $ result );
356+
357+ $ result = $ this ->getPrivateMethodInvoker ($ db , 'convertTimezoneToOffset ' )('-08:00 ' );
358+ $ this ->assertSame ('-08:00 ' , $ result );
359+
360+ $ result = $ this ->getPrivateMethodInvoker ($ db , 'convertTimezoneToOffset ' )('+00:00 ' );
361+ $ this ->assertSame ('+00:00 ' , $ result );
362+ }
363+
364+ public function testConvertTimezoneToOffsetWithNamedTimezone (): void
365+ {
366+ $ db = new MockConnection ($ this ->options );
367+
368+ // UTC should always be +00:00
369+ $ result = $ this ->getPrivateMethodInvoker ($ db , 'convertTimezoneToOffset ' )('UTC ' );
370+ $ this ->assertSame ('+00:00 ' , $ result );
371+
372+ $ result = $ this ->getPrivateMethodInvoker ($ db , 'convertTimezoneToOffset ' )('America/New_York ' );
373+ $ this ->assertContains ($ result , ['-05:00 ' , '-04:00 ' ]); // EST/EDT
374+
375+ $ result = $ this ->getPrivateMethodInvoker ($ db , 'convertTimezoneToOffset ' )('Europe/Paris ' );
376+ $ this ->assertContains ($ result , ['+01:00 ' , '+02:00 ' ]); // CET/CEST
377+
378+ $ result = $ this ->getPrivateMethodInvoker ($ db , 'convertTimezoneToOffset ' )('Asia/Tokyo ' );
379+ $ this ->assertSame ('+09:00 ' , $ result ); // JST (no DST)
380+ }
381+
382+ public function testConvertTimezoneToOffsetWithInvalidTimezone (): void
383+ {
384+ $ db = new MockConnection ($ this ->options );
385+
386+ $ result = $ this ->getPrivateMethodInvoker ($ db , 'convertTimezoneToOffset ' )('Invalid/Timezone ' );
387+ $ this ->assertSame ('+00:00 ' , $ result );
388+ }
389+
390+ public function testGetSessionTimezoneWithFalse (): void
391+ {
392+ $ options = $ this ->options ;
393+ $ options ['timezone ' ] = false ;
394+ $ db = new MockConnection ($ options );
395+
396+ $ result = $ this ->getPrivateMethodInvoker ($ db , 'getSessionTimezone ' )();
397+ $ this ->assertNull ($ result );
398+ }
399+
400+ public function testGetSessionTimezoneWithTrue (): void
401+ {
402+ $ options = $ this ->options ;
403+ $ options ['timezone ' ] = true ;
404+ $ db = new MockConnection ($ options );
405+
406+ $ result = $ this ->getPrivateMethodInvoker ($ db , 'getSessionTimezone ' )();
407+ $ this ->assertSame ('+00:00 ' , $ result ); // UTC = +00:00
408+ }
409+
410+ public function testGetSessionTimezoneWithSpecificOffset (): void
411+ {
412+ $ options = $ this ->options ;
413+ $ options ['timezone ' ] = '+05:30 ' ;
414+ $ db = new MockConnection ($ options );
415+
416+ $ result = $ this ->getPrivateMethodInvoker ($ db , 'getSessionTimezone ' )();
417+ $ this ->assertSame ('+05:30 ' , $ result );
418+ }
419+
420+ public function testGetSessionTimezoneWithSpecificNamedTimezone (): void
421+ {
422+ $ options = $ this ->options ;
423+ $ options ['timezone ' ] = 'America/Chicago ' ;
424+ $ db = new MockConnection ($ options );
425+
426+ $ result = $ this ->getPrivateMethodInvoker ($ db , 'getSessionTimezone ' )();
427+ $ this ->assertContains ($ result , ['-06:00 ' , '-05:00 ' ]);
428+ }
429+
430+ public function testGetSessionTimezoneWithoutTimezoneKey (): void
431+ {
432+ $ db = new MockConnection ($ this ->options );
433+
434+ $ result = $ this ->getPrivateMethodInvoker ($ db , 'getSessionTimezone ' )();
435+ $ this ->assertNull ($ result );
436+ }
348437}
0 commit comments