diff --git a/src/Credit/CreditSystem.php b/src/Credit/CreditSystem.php index 8c1f04d..ab07f20 100644 --- a/src/Credit/CreditSystem.php +++ b/src/Credit/CreditSystem.php @@ -39,7 +39,7 @@ public function __construct( public function getUserCredit($userid) { - $result = $this->db->query("SELECT credit FROM credit WHERE id = '$userid'"); + $result = $this->db->query("SELECT credit FROM credit WHERE userId = '$userid'"); if ($result->rowCount() == 0) { return 0; } diff --git a/tests/Credit/CreditSystemTest.php b/tests/Credit/CreditSystemTest.php index 7f5b4a9..f95656e 100644 --- a/tests/Credit/CreditSystemTest.php +++ b/tests/Credit/CreditSystemTest.php @@ -83,7 +83,7 @@ public function testGetUserCredit() $db = $this->createMock(DbInterface::class); $db->expects($this->once()) ->method('query') - ->with("SELECT credit FROM credit WHERE id = '$userId'") + ->with("SELECT credit FROM credit WHERE userId = '$userId'") ->willReturn($dbResult); $creditSystem = new CreditSystem(['isEnabled' => true], $db); @@ -102,7 +102,7 @@ public function testGetUserCreditNotFoundUser() $db = $this->createMock(DbInterface::class); $db->expects($this->once()) ->method('query') - ->with("SELECT credit FROM credit WHERE id = '$userId'") + ->with("SELECT credit FROM credit WHERE userId = '$userId'") ->willReturn($dbResult); $creditSystem = new CreditSystem(['isEnabled' => true], $db);