From 0e304e6df99d92633f381312ae096e13cf2e5912 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Rancoud?= Date: Mon, 11 Dec 2023 19:22:39 +0100 Subject: [PATCH 1/4] feat: add php 8.3 and 8.4 for github workflow test --- .github/workflows/test.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0becd01..1ebec0d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -18,6 +18,8 @@ jobs: - '8.0' - '8.1' - '8.2' + - '8.3' + - '8.4' steps: - name: Checkout From d70ebe62da5e3daffdfc854adf457d78ef9a5338 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Rancoud?= Date: Mon, 11 Dec 2023 22:45:45 +0100 Subject: [PATCH 2/4] remove php 8.4 --- .github/workflows/test.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1ebec0d..525b6eb 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -19,7 +19,6 @@ jobs: - '8.1' - '8.2' - '8.3' - - '8.4' steps: - name: Checkout From c399ec80e85ae2e72dc9c3399e2c77f4c8de7625 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Rancoud?= Date: Mon, 11 Dec 2023 22:57:20 +0100 Subject: [PATCH 3/4] fix tests for php 8.3 --- tests/DatabaseNamedInstancesTest.php | 46 +++++++++++++++++++++++----- 1 file changed, 39 insertions(+), 7 deletions(-) diff --git a/tests/DatabaseNamedInstancesTest.php b/tests/DatabaseNamedInstancesTest.php index 603424a..d2d4be5 100644 --- a/tests/DatabaseNamedInstancesTest.php +++ b/tests/DatabaseNamedInstancesTest.php @@ -38,7 +38,12 @@ public function testSetInstance(): void $class = new ReflectionClass(Database::class); $reflectedProperty = $class->getProperty('instances'); $reflectedProperty->setAccessible(true); - $reflectedProperty->setValue([]); + + if (\PHP_MAJOR_VERSION === 8 && \PHP_MINOR_VERSION >= 3) { + $reflectedProperty->setStaticPropertyValue('instances', []); + } else { + $reflectedProperty->setValue([]); + } $db1 = Database::setInstance(new Configurator($this->params)); @@ -55,7 +60,11 @@ public function testSetInstance(): void static::assertInstanceOf(Database::class, $propertiesTwo['instances']['secondary']); static::assertSame($db2, $propertiesTwo['instances']['secondary']); - $reflectedProperty->setValue([]); + if (\PHP_MAJOR_VERSION === 8 && \PHP_MINOR_VERSION >= 3) { + $reflectedProperty->setStaticPropertyValue('instances', []); + } else { + $reflectedProperty->setValue([]); + } } /** @@ -66,7 +75,12 @@ public function testSetInstanceThrowException(): void $class = new ReflectionClass(Database::class); $reflectedProperty = $class->getProperty('instances'); $reflectedProperty->setAccessible(true); - $reflectedProperty->setValue([]); + + if (\PHP_MAJOR_VERSION === 8 && \PHP_MINOR_VERSION >= 3) { + $reflectedProperty->setStaticPropertyValue('instances', []); + } else { + $reflectedProperty->setValue([]); + } $this->expectException(DatabaseException::class); $this->expectExceptionMessage('Cannot overwrite instance "primary"'); @@ -83,7 +97,12 @@ public function testHasInstance(): void $class = new ReflectionClass(Database::class); $reflectedProperty = $class->getProperty('instances'); $reflectedProperty->setAccessible(true); - $reflectedProperty->setValue([]); + + if (\PHP_MAJOR_VERSION === 8 && \PHP_MINOR_VERSION >= 3) { + $reflectedProperty->setStaticPropertyValue('instances', []); + } else { + $reflectedProperty->setValue([]); + } static::assertFalse(Database::hasInstance()); @@ -97,7 +116,11 @@ public function testHasInstance(): void static::assertTrue(Database::hasInstance('secondary')); - $reflectedProperty->setValue([]); + if (\PHP_MAJOR_VERSION === 8 && \PHP_MINOR_VERSION >= 3) { + $reflectedProperty->setStaticPropertyValue('instances', []); + } else { + $reflectedProperty->setValue([]); + } } /** @@ -108,7 +131,12 @@ public function testGetInstance(): void $class = new ReflectionClass(Database::class); $reflectedProperty = $class->getProperty('instances'); $reflectedProperty->setAccessible(true); - $reflectedProperty->setValue([]); + + if (\PHP_MAJOR_VERSION === 8 && \PHP_MINOR_VERSION >= 3) { + $reflectedProperty->setStaticPropertyValue('instances', []); + } else { + $reflectedProperty->setValue([]); + } static::assertNull(Database::getInstance()); static::assertNull(Database::getInstance('secondary')); @@ -122,6 +150,10 @@ public function testGetInstance(): void static::assertSame($db1, Database::getInstance()); static::assertSame($db2, Database::getInstance('secondary')); - $reflectedProperty->setValue([]); + if (\PHP_MAJOR_VERSION === 8 && \PHP_MINOR_VERSION >= 3) { + $reflectedProperty->setStaticPropertyValue('instances', []); + } else { + $reflectedProperty->setValue([]); + } } } From f15580a92ed6c66a07bc6265684773b99b5189d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Rancoud?= Date: Mon, 11 Dec 2023 23:02:45 +0100 Subject: [PATCH 4/4] fix tests for php 8.3 --- tests/DatabaseNamedInstancesTest.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/DatabaseNamedInstancesTest.php b/tests/DatabaseNamedInstancesTest.php index d2d4be5..f5e2a1e 100644 --- a/tests/DatabaseNamedInstancesTest.php +++ b/tests/DatabaseNamedInstancesTest.php @@ -40,7 +40,7 @@ public function testSetInstance(): void $reflectedProperty->setAccessible(true); if (\PHP_MAJOR_VERSION === 8 && \PHP_MINOR_VERSION >= 3) { - $reflectedProperty->setStaticPropertyValue('instances', []); + $class->setStaticPropertyValue('instances', []); } else { $reflectedProperty->setValue([]); } @@ -61,7 +61,7 @@ public function testSetInstance(): void static::assertSame($db2, $propertiesTwo['instances']['secondary']); if (\PHP_MAJOR_VERSION === 8 && \PHP_MINOR_VERSION >= 3) { - $reflectedProperty->setStaticPropertyValue('instances', []); + $class->setStaticPropertyValue('instances', []); } else { $reflectedProperty->setValue([]); } @@ -77,7 +77,7 @@ public function testSetInstanceThrowException(): void $reflectedProperty->setAccessible(true); if (\PHP_MAJOR_VERSION === 8 && \PHP_MINOR_VERSION >= 3) { - $reflectedProperty->setStaticPropertyValue('instances', []); + $class->setStaticPropertyValue('instances', []); } else { $reflectedProperty->setValue([]); } @@ -99,7 +99,7 @@ public function testHasInstance(): void $reflectedProperty->setAccessible(true); if (\PHP_MAJOR_VERSION === 8 && \PHP_MINOR_VERSION >= 3) { - $reflectedProperty->setStaticPropertyValue('instances', []); + $class->setStaticPropertyValue('instances', []); } else { $reflectedProperty->setValue([]); } @@ -117,7 +117,7 @@ public function testHasInstance(): void static::assertTrue(Database::hasInstance('secondary')); if (\PHP_MAJOR_VERSION === 8 && \PHP_MINOR_VERSION >= 3) { - $reflectedProperty->setStaticPropertyValue('instances', []); + $class->setStaticPropertyValue('instances', []); } else { $reflectedProperty->setValue([]); } @@ -133,7 +133,7 @@ public function testGetInstance(): void $reflectedProperty->setAccessible(true); if (\PHP_MAJOR_VERSION === 8 && \PHP_MINOR_VERSION >= 3) { - $reflectedProperty->setStaticPropertyValue('instances', []); + $class->setStaticPropertyValue('instances', []); } else { $reflectedProperty->setValue([]); } @@ -151,7 +151,7 @@ public function testGetInstance(): void static::assertSame($db2, Database::getInstance('secondary')); if (\PHP_MAJOR_VERSION === 8 && \PHP_MINOR_VERSION >= 3) { - $reflectedProperty->setStaticPropertyValue('instances', []); + $class->setStaticPropertyValue('instances', []); } else { $reflectedProperty->setValue([]); }