@@ -41,7 +41,6 @@ final class BaseConnectionTest extends CIUnitTestCase
4141 'swapPre ' => '' ,
4242 'encrypt ' => false ,
4343 'compress ' => false ,
44- 'strictOn ' => true ,
4544 'failover ' => [],
4645 'dateFormat ' => [
4746 'date ' => 'Y-m-d ' ,
@@ -64,7 +63,6 @@ final class BaseConnectionTest extends CIUnitTestCase
6463 'swapPre ' => '' ,
6564 'encrypt ' => false ,
6665 'compress ' => false ,
67- 'strictOn ' => true ,
6866 'failover ' => [],
6967 ];
7068
@@ -84,7 +82,6 @@ public function testSavesConfigOptions(): void
8482 $ this ->assertSame ('' , $ db ->swapPre );
8583 $ this ->assertFalse ($ db ->encrypt );
8684 $ this ->assertFalse ($ db ->compress );
87- $ this ->assertTrue ($ db ->strictOn );
8885 $ this ->assertSame ([], $ db ->failover );
8986 $ this ->assertSame ([
9087 'date ' => 'Y-m-d ' ,
@@ -346,6 +343,96 @@ public static function provideEscapeIdentifier(): iterable
346343 ];
347344 }
348345
346+ public function testConvertTimezoneToOffsetWithOffset (): void
347+ {
348+ $ db = new MockConnection ($ this ->options );
349+
350+ // Offset strings should be returned as-is
351+ $ result = $ this ->getPrivateMethodInvoker ($ db , 'convertTimezoneToOffset ' )('+05:30 ' );
352+ $ this ->assertSame ('+05:30 ' , $ result );
353+
354+ $ result = $ this ->getPrivateMethodInvoker ($ db , 'convertTimezoneToOffset ' )('-08:00 ' );
355+ $ this ->assertSame ('-08:00 ' , $ result );
356+
357+ $ result = $ this ->getPrivateMethodInvoker ($ db , 'convertTimezoneToOffset ' )('+00:00 ' );
358+ $ this ->assertSame ('+00:00 ' , $ result );
359+ }
360+
361+ public function testConvertTimezoneToOffsetWithNamedTimezone (): void
362+ {
363+ $ db = new MockConnection ($ this ->options );
364+
365+ // UTC should always be +00:00
366+ $ result = $ this ->getPrivateMethodInvoker ($ db , 'convertTimezoneToOffset ' )('UTC ' );
367+ $ this ->assertSame ('+00:00 ' , $ result );
368+
369+ $ result = $ this ->getPrivateMethodInvoker ($ db , 'convertTimezoneToOffset ' )('America/New_York ' );
370+ $ this ->assertContains ($ result , ['-05:00 ' , '-04:00 ' ]); // EST/EDT
371+
372+ $ result = $ this ->getPrivateMethodInvoker ($ db , 'convertTimezoneToOffset ' )('Europe/Paris ' );
373+ $ this ->assertContains ($ result , ['+01:00 ' , '+02:00 ' ]); // CET/CEST
374+
375+ $ result = $ this ->getPrivateMethodInvoker ($ db , 'convertTimezoneToOffset ' )('Asia/Tokyo ' );
376+ $ this ->assertSame ('+09:00 ' , $ result ); // JST (no DST)
377+ }
378+
379+ public function testConvertTimezoneToOffsetWithInvalidTimezone (): void
380+ {
381+ $ db = new MockConnection ($ this ->options );
382+
383+ $ result = $ this ->getPrivateMethodInvoker ($ db , 'convertTimezoneToOffset ' )('Invalid/Timezone ' );
384+ $ this ->assertSame ('+00:00 ' , $ result );
385+ $ this ->assertLogged ('error ' , "Invalid timezone 'Invalid/Timezone'. Falling back to UTC. DateTimeZone::__construct(): Unknown or bad timezone (Invalid/Timezone). " );
386+ }
387+
388+ public function testGetSessionTimezoneWithFalse (): void
389+ {
390+ $ options = $ this ->options ;
391+ $ options ['timezone ' ] = false ;
392+ $ db = new MockConnection ($ options );
393+
394+ $ result = $ this ->getPrivateMethodInvoker ($ db , 'getSessionTimezone ' )();
395+ $ this ->assertNull ($ result );
396+ }
397+
398+ public function testGetSessionTimezoneWithTrue (): void
399+ {
400+ $ options = $ this ->options ;
401+ $ options ['timezone ' ] = true ;
402+ $ db = new MockConnection ($ options );
403+
404+ $ result = $ this ->getPrivateMethodInvoker ($ db , 'getSessionTimezone ' )();
405+ $ this ->assertSame ('+00:00 ' , $ result ); // UTC = +00:00
406+ }
407+
408+ public function testGetSessionTimezoneWithSpecificOffset (): void
409+ {
410+ $ options = $ this ->options ;
411+ $ options ['timezone ' ] = '+05:30 ' ;
412+ $ db = new MockConnection ($ options );
413+
414+ $ result = $ this ->getPrivateMethodInvoker ($ db , 'getSessionTimezone ' )();
415+ $ this ->assertSame ('+05:30 ' , $ result );
416+ }
417+
418+ public function testGetSessionTimezoneWithSpecificNamedTimezone (): void
419+ {
420+ $ options = $ this ->options ;
421+ $ options ['timezone ' ] = 'America/Chicago ' ;
422+ $ db = new MockConnection ($ options );
423+
424+ $ result = $ this ->getPrivateMethodInvoker ($ db , 'getSessionTimezone ' )();
425+ $ this ->assertContains ($ result , ['-06:00 ' , '-05:00 ' ]);
426+ }
427+
428+ public function testGetSessionTimezoneWithoutTimezoneKey (): void
429+ {
430+ $ db = new MockConnection ($ this ->options );
431+
432+ $ result = $ this ->getPrivateMethodInvoker ($ db , 'getSessionTimezone ' )();
433+ $ this ->assertNull ($ result );
434+ }
435+
349436 public function testCallFunctionDoesNotDoublePrefixAlreadyPrefixedName (): void
350437 {
351438 $ db = new class ($ this ->options ) extends MockConnection {
@@ -370,3 +457,4 @@ protected function getDriverFunctionPrefix(): string
370457 $ this ->assertTrue ($ db ->callFunction ('contains ' , 'CodeIgniter ' , 'Ignite ' ));
371458 }
372459}
460+
0 commit comments