From 3887d5e38ec525535611533dd79b09f5e454baa7 Mon Sep 17 00:00:00 2001 From: "John Paul E. Balandan, CPA" Date: Sun, 16 Mar 2025 01:49:10 +0800 Subject: [PATCH] refactor: fix tests after smarter `getPrivateMethodInvoker()` return --- tests/system/ControllerTest.php | 8 ++++++-- tests/system/Database/ConfigTest.php | 5 +++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/tests/system/ControllerTest.php b/tests/system/ControllerTest.php index 6bf50ba0bd76..113b02c14deb 100644 --- a/tests/system/ControllerTest.php +++ b/tests/system/ControllerTest.php @@ -89,13 +89,17 @@ public function testConstructorHTTPS(): void $_SERVER = $original; // restore so code coverage doesn't break } - public function testCachePage(): void + public function testCachePageSetsTtl(): void { $this->controller = new Controller(); $this->controller->initController($this->request, $this->response, $this->logger); $method = self::getPrivateMethodInvoker($this->controller, 'cachePage'); - $this->assertNull($method(10)); + + $this->assertSame(0, self::getPrivateProperty(service('responsecache'), 'ttl')); + + $method(10); + $this->assertSame(10, self::getPrivateProperty(service('responsecache'), 'ttl')); } public function testValidate(): void diff --git a/tests/system/Database/ConfigTest.php b/tests/system/Database/ConfigTest.php index f64434e561bc..1d2482e0ad87 100644 --- a/tests/system/Database/ConfigTest.php +++ b/tests/system/Database/ConfigTest.php @@ -13,6 +13,7 @@ namespace CodeIgniter\Database; +use CodeIgniter\Database\Postgre\Connection as PostgreConnection; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\ReflectionHelper; use PHPUnit\Framework\Attributes\DataProvider; @@ -149,7 +150,7 @@ public function testConnectionGroupWithDSN(): void public function testConnectionGroupWithDSNPostgre(): void { $conn = Config::connect($this->dsnGroupPostgre, false); - $this->assertInstanceOf(BaseConnection::class, $conn); + $this->assertInstanceOf(PostgreConnection::class, $conn); $this->assertSame('', $this->getPrivateProperty($conn, 'DSN')); $this->assertSame('localhost', $this->getPrivateProperty($conn, 'hostname')); @@ -205,7 +206,7 @@ public function testConvertDSN(string $input, string $expected): void // Should deprecate? $this->dsnGroupPostgreNative['DSN'] = $input; $conn = Config::connect($this->dsnGroupPostgreNative, false); - $this->assertInstanceOf(BaseConnection::class, $conn); + $this->assertInstanceOf(PostgreConnection::class, $conn); $method = self::getPrivateMethodInvoker($conn, 'convertDSN'); $method();