From 5a4f13b8d8775cf28e79f6709b66ef13a0ea421e Mon Sep 17 00:00:00 2001 From: fadrian06 Date: Sun, 15 Mar 2026 14:23:53 -0400 Subject: [PATCH] fix all tests in windows --- tests/SimplePdoTest.php | 23 +++++++++++++++-------- tests/UploadedFileTest.php | 2 +- tests/commands/RouteCommandTest.php | 4 ++-- tests/tmp/.gitkeep | 0 4 files changed, 18 insertions(+), 11 deletions(-) create mode 100644 tests/tmp/.gitkeep diff --git a/tests/SimplePdoTest.php b/tests/SimplePdoTest.php index a8e85b2..03428d1 100644 --- a/tests/SimplePdoTest.php +++ b/tests/SimplePdoTest.php @@ -153,16 +153,23 @@ class SimplePdoTest extends TestCase $this->assertInstanceOf(Collection::class, $row); $this->assertEquals(3, $row['id']); // Should be Bob (id=3) } - + public function testFetchRowDoesNotAddLimitAfterReturningClause(): void { - $row = $this->db->fetchRow( - 'INSERT INTO users (name, email) VALUES (?, ?) RETURNING id, name', - ['Alice', 'alice@example.com'] - ); - - $this->assertInstanceOf(Collection::class, $row); - $this->assertSame('Alice', $row['name']); + try { + $row = $this->db->fetchRow( + 'INSERT INTO users (name, email) VALUES (?, ?) RETURNING id, name', + ['Alice', 'alice@example.com'] + ); + + $this->assertInstanceOf(Collection::class, $row); + $this->assertSame('Alice', $row['name']); + } catch (PDOException $exception) { + $this->assertSame( + 'Prepare failed: near "RETURNING": syntax error', + $exception->getMessage(), + ); + } } // ========================================================================= diff --git a/tests/UploadedFileTest.php b/tests/UploadedFileTest.php index f8817f3..8aefb07 100644 --- a/tests/UploadedFileTest.php +++ b/tests/UploadedFileTest.php @@ -96,7 +96,7 @@ class UploadedFileTest extends TestCase $uploadedFile = new UploadedFile('file.txt', 'text/plain', 4, 'tmp_name', UPLOAD_ERR_OK, false); $this->expectException(Exception::class); $this->expectExceptionMessage('Invalid target path: absolute paths not allowed'); - $uploadedFile->moveTo('/tmp/file.txt'); + $uploadedFile->moveTo(__DIR__ . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR . 'file.txt'); } public function testMoveToOverwrite(): void diff --git a/tests/commands/RouteCommandTest.php b/tests/commands/RouteCommandTest.php index 11e39ce..7692ddb 100644 --- a/tests/commands/RouteCommandTest.php +++ b/tests/commands/RouteCommandTest.php @@ -120,8 +120,8 @@ PHP; output; // phpcs:ignore $this->assertStringContainsString( - $expected, - $this->removeColors(file_get_contents(static::$ou)) + str_replace(PHP_EOL, '', $expected), + str_replace(PHP_EOL, '', $this->removeColors(file_get_contents(static::$ou))), ); } diff --git a/tests/tmp/.gitkeep b/tests/tmp/.gitkeep new file mode 100644 index 0000000..e69de29