fixtureTable = 'DB2_TEST.DB2T_' . strtoupper(bin2hex(random_bytes(6))); $db = $this->db(); $db->statement(" CREATE TABLE {$this->fixtureTable} ( ID INTEGER NOT NULL PRIMARY KEY, NULLABLE_TEXT VARCHAR(100), NULLABLE_DATE DATE, NULLABLE_TIME TIME, NULLABLE_TIMESTAMP TIMESTAMP ) "); $db->statement(" INSERT INTO {$this->fixtureTable} (ID, NULLABLE_TEXT, NULLABLE_DATE, NULLABLE_TIME, NULLABLE_TIMESTAMP) VALUES (1, NULL, NULL, NULL, NULL) "); $db->statement(" INSERT INTO {$this->fixtureTable} (ID, NULLABLE_TEXT, NULLABLE_DATE, NULLABLE_TIME, NULLABLE_TIMESTAMP) VALUES ( 2, '', DATE('2026-11-11'), TIME('10:15:30'), TIMESTAMP('2026-11-11 10:15:30') ) "); } protected function tearDown(): void { try { if ($this->fixtureTable !== '') { $this->db()->statement( "DROP TABLE {$this->fixtureTable}" ); } } finally { parent::tearDown(); } } public function test_null_values_are_restored(): void { $row = $this->db()->table($this->fixtureTable) ->where('ID', 1) ->first(); $this->assertNull($row->NULLABLE_TEXT); $this->assertNull($row->NULLABLE_DATE); $this->assertNull($row->NULLABLE_TIME); $this->assertNull($row->NULLABLE_TIMESTAMP); } public function test_empty_string_is_not_converted_to_null(): void { $row = $this->db()->table($this->fixtureTable) ->where('ID', 2) ->first(); $this->assertSame('', $row->NULLABLE_TEXT); } public function test_non_null_temporal_values_survive(): void { $row = $this->db()->table($this->fixtureTable) ->where('ID', 2) ->first(); $this->assertNotNull($row->NULLABLE_DATE); $this->assertNotNull($row->NULLABLE_TIME); $this->assertNotNull($row->NULLABLE_TIMESTAMP); } public function test_generated_indicators_are_hidden(): void { $row = $this->db()->table($this->fixtureTable) ->where('ID', 1) ->first(); foreach (array_keys((array) $row) as $column) { $this->assertDoesNotMatchRegularExpression( '/^__db2_null_flag_\d+$/i', $column ); } } public function test_nullable_aliases_are_preserved(): void { $row = $this->db()->table($this->fixtureTable) ->select('NULLABLE_TEXT as aliased_text') ->where('ID', 1) ->first(); $this->assertTrue( property_exists($row, 'aliased_text') ); $this->assertNull($row->aliased_text); } }