Skip to content

Commit

Permalink
fix finding user by number
Browse files Browse the repository at this point in the history
  • Loading branch information
sveneld committed Mar 2, 2024
1 parent 0167b44 commit bb97fb8
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Db/MysqliDb.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/User/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -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"];
}
Expand Down
2 changes: 1 addition & 1 deletion tests/User/UserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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, [])
Expand Down

0 comments on commit bb97fb8

Please sign in to comment.