From 9e8ccd192d286c9fac42eeb49757ec22c3fa600e Mon Sep 17 00:00:00 2001 From: 0x1026 <69076992+0x1026@users.noreply.github.com> Date: Sun, 24 Nov 2024 18:01:58 +0100 Subject: [PATCH] test: skip database tests on CI and format DatabaseTest methods --- tests/DatabaseTest.php | 46 +++++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/tests/DatabaseTest.php b/tests/DatabaseTest.php index 057403e1..f6935719 100644 --- a/tests/DatabaseTest.php +++ b/tests/DatabaseTest.php @@ -7,27 +7,31 @@ #[RequiresPhpExtension('pdo_mysql')] final class DatabaseTest extends TestCase { - public function testConnection() - { - $connection = Database::connect(); - $this->assertInstanceOf(PDO::class, $connection); - } + protected function setUp(): void + { + getenv('CI') && $this->markTestSkipped('Database tests are not supported on CI'); + } + public function testConnection() + { + $connection = Database::connect(); + $this->assertInstanceOf(PDO::class, $connection); + } - public function testPrepareAndExecute() - { - $query = 'SELECT 1'; - $result = Database::prepareAndExecute($query); - $this->assertIsArray($result); - $this->assertNotEmpty($result); - } + public function testPrepareAndExecute() + { + $query = 'SELECT 1'; + $result = Database::prepareAndExecute($query); + $this->assertIsArray($result); + $this->assertNotEmpty($result); + } - public function testPrepareAndExecuteWithParams() - { - $query = 'SELECT :value'; - $params = ['value' => 1]; - $result = Database::prepareAndExecute($query, $params); - $this->assertIsArray($result); - $this->assertNotEmpty($result); - $this->assertEquals(1, $result[0]['1']); - } + public function testPrepareAndExecuteWithParams() + { + $query = 'SELECT :value'; + $params = ['value' => 1]; + $result = Database::prepareAndExecute($query, $params); + $this->assertIsArray($result); + $this->assertNotEmpty($result); + $this->assertEquals(1, $result[0]['1']); + } }