From eb8caaa5e794fdf0d4e855744832850a079f0035 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 7 Nov 2020 11:44:39 +0000 Subject: [PATCH] Restore the connection check --- src/Database/Database.php | 11 +++++------ tests/functional/DependencyCheckTest.php | 6 +++--- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/Database/Database.php b/src/Database/Database.php index 4ca454821b..273c2985c6 100644 --- a/src/Database/Database.php +++ b/src/Database/Database.php @@ -385,12 +385,11 @@ class Database switch ($this->driver) { case self::PDO: - $connected = true; -// $r = $this->p("SELECT 1"); -// if ($this->isResult($r)) { -// $row = $this->toArray($r); -// $connected = ($row[0]['1'] == '1'); -// } + $r = $this->p("SELECT 1"); + if ($this->isResult($r)) { + $row = $this->toArray($r); + $connected = ($row[0]['1'] == '1'); + } break; case self::MYSQLI: $connected = $this->connection->ping(); diff --git a/tests/functional/DependencyCheckTest.php b/tests/functional/DependencyCheckTest.php index 4694f3d0ed..fcb16e14cc 100644 --- a/tests/functional/DependencyCheckTest.php +++ b/tests/functional/DependencyCheckTest.php @@ -119,9 +119,9 @@ class DependencyCheckTest extends TestCase $database = $this->dice->create(Database::class); self::assertInstanceOf(Database::class, $database); - self::assertContains($database->getDriver(), [Database::PDO, Database::MYSQLI]); - self::assertNotNull($database->getConnection()); - self::assertTrue($database->connected()); + self::assertContains($database->getDriver(), [Database::PDO, Database::MYSQLI], 'The driver returns an unexpected value'); + self::assertNotNull($database->getConnection(), 'There is no database connection'); + self::assertTrue($database->connected(), 'The database is not connected'); } public function testAppMode()