From b3cf454aff8855a24ce030763bf847ad0a0ddf3f Mon Sep 17 00:00:00 2001 From: Connor Smyth Date: Fri, 1 Nov 2024 10:13:49 -0400 Subject: [PATCH] Making one line change and adding unit test (#9) --- src/Pdo.php | 2 +- tests/Unit/PdoQueriesTest.php | 24 +++++++++++++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/Pdo.php b/src/Pdo.php index be4841e..29ac19d 100644 --- a/src/Pdo.php +++ b/src/Pdo.php @@ -74,7 +74,7 @@ public function inTransaction(): bool return $this->inTransaction; } - public function exec($statement): false|int + public function exec(string $statement): false|int { $result = $this->query($statement); diff --git a/tests/Unit/PdoQueriesTest.php b/tests/Unit/PdoQueriesTest.php index 1d7c19d..866bbfe 100644 --- a/tests/Unit/PdoQueriesTest.php +++ b/tests/Unit/PdoQueriesTest.php @@ -6,7 +6,6 @@ use PHPUnit\Framework\TestCase; use Pseudo\Pdo; -use Pseudo\Result; use Pseudo\UnitTest\SampleModels\PdoQueries; use RuntimeException; @@ -48,6 +47,29 @@ public function testSelectQueryWithNoParameters(): void ); } + public function testSelectSingleRow(): void + { + $this->pdo->mock( + 'SELECT * FROM users ORDER BY id DESC LIMIT 1', + [], + [ + [ + 'id' => 1, + 'name' => 'John Doe', + ] + ] + ); + + $data = $this->pdoQueries->selectSingleRow(); + $this->assertEquals( + [ + 'id' => 1, + 'name' => 'John Doe', + ], + $data + ); + } + public function testSelectQueryWithPlaceholders(): void { $this->pdo->mock(