From bb97fb8aa11b38130e788a67f464972ee0663a01 Mon Sep 17 00:00:00 2001 From: Sveneld Date: Sat, 2 Mar 2024 17:29:27 +0100 Subject: [PATCH] fix finding user by number --- src/Db/MysqliDb.php | 2 +- src/User/User.php | 2 +- tests/User/UserTest.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Db/MysqliDb.php b/src/Db/MysqliDb.php index 9d3c91a..be69e50 100644 --- a/src/Db/MysqliDb.php +++ b/src/Db/MysqliDb.php @@ -64,7 +64,7 @@ public function query($query, $params = array()) if ($this->throwException) { throw new \RuntimeException('DB error in : ' . $query); } else { - trigger_error('DB error in : ' . $query, E_USER_ERROR); + trigger_error('DB error' . ' ' . $this->conn->error . ' ' . _('in') . ': ' . $query, E_USER_ERROR); die(_('DB error') . ' ' . $this->conn->error . ' ' . _('in') . ': ' . $query); } } diff --git a/src/User/User.php b/src/User/User.php index 6a716c8..250a2f8 100644 --- a/src/User/User.php +++ b/src/User/User.php @@ -19,7 +19,7 @@ public function __construct( public function findUserIdByNumber($number) { - $result = $this->db->query("SELECT userId FROM users WHERE userNumber='$number'"); + $result = $this->db->query("SELECT userId FROM users WHERE number='$number'"); if ($result->num_rows == 1) { return $result->fetch_assoc()["userId"]; } diff --git a/tests/User/UserTest.php b/tests/User/UserTest.php index 2707617..1b4d70e 100644 --- a/tests/User/UserTest.php +++ b/tests/User/UserTest.php @@ -16,7 +16,7 @@ public function testFindUserIdByNumberReturnsUserId() $dbMock = $this->createMock(DbInterface::class); $dbMock->expects($this->exactly(2)) ->method('query') - ->with("SELECT userId FROM users WHERE userNumber='{$userNumber}'") + ->with("SELECT userId FROM users WHERE number='{$userNumber}'") ->willReturnOnConsecutiveCalls( new MysqliResult(1, [['userId' => $expectedUserId]]), new MysqliResult(0, [])