From 9681cd20c88dcf527545b2d5bb4f76bcb554b7f8 Mon Sep 17 00:00:00 2001 From: Ambrose Casanova <279373485+ambrose5773@users.noreply.github.com> Date: Fri, 4 Sep 2026 03:46:22 +0000 Subject: [PATCH] test: tolerate PDO numeric strings on PHP < 8.1 assertEquals for integer-ish fetchField values; keep assertSame for false / empty string and assertNull for SQL NULL. --- tests/PdoWrapperTest.php | 6 ++++-- tests/SimplePdoTest.php | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/PdoWrapperTest.php b/tests/PdoWrapperTest.php index d3a2928..132156b 100644 --- a/tests/PdoWrapperTest.php +++ b/tests/PdoWrapperTest.php @@ -68,7 +68,8 @@ class PdoWrapperTest extends TestCase public function testFetchField(): void { $id = $this->pdo_wrapper->fetchField('SELECT id FROM test WHERE name = ?', ['two']); - $this->assertSame(2, $id); + // PDO SQLite may return numeric strings on PHP < 8.1 + $this->assertEquals(2, $id); } public function testFetchFieldReturnsFalseWhenNoResults(): void @@ -87,7 +88,8 @@ class PdoWrapperTest extends TestCase public function testFetchFieldReturnsZero(): void { $value = $this->pdo_wrapper->fetchField('SELECT 0'); - $this->assertSame(0, $value); + // PDO SQLite may return '0' on PHP < 8.1 + $this->assertEquals(0, $value); } public function testFetchFieldReturnsEmptyString(): void diff --git a/tests/SimplePdoTest.php b/tests/SimplePdoTest.php index c4441af..0143381 100644 --- a/tests/SimplePdoTest.php +++ b/tests/SimplePdoTest.php @@ -466,7 +466,8 @@ class SimplePdoTest extends TestCase public function testFetchFieldReturnsFirstColumn(): void { $id = $this->db->fetchField('SELECT id, name FROM users WHERE id = ?', [1]); - $this->assertSame(1, $id); + // PDO SQLite may return numeric strings on PHP < 8.1 + $this->assertEquals(1, $id); } public function testFetchFieldReturnsFalseWhenNoResults(): void @@ -485,7 +486,8 @@ class SimplePdoTest extends TestCase public function testFetchFieldReturnsZero(): void { $value = $this->db->fetchField('SELECT 0'); - $this->assertSame(0, $value); + // PDO SQLite may return '0' on PHP < 8.1 + $this->assertEquals(0, $value); } public function testFetchFieldReturnsEmptyString(): void