From 7bcdd2c7e27f0cb67884caae9145e64c3745c787 Mon Sep 17 00:00:00 2001 From: Harald Leithner Date: Sun, 16 Jun 2024 10:57:32 +0200 Subject: [PATCH 1/2] Fix CS --- src/Mysqli/MysqliStatement.php | 1 - src/Sqlsrv/SqlsrvStatement.php | 1 - 2 files changed, 2 deletions(-) diff --git a/src/Mysqli/MysqliStatement.php b/src/Mysqli/MysqliStatement.php index e31dfd53..f689c0b4 100644 --- a/src/Mysqli/MysqliStatement.php +++ b/src/Mysqli/MysqliStatement.php @@ -200,7 +200,6 @@ public function prepareParameterKeyMapping($sql) if (isset($mapping[$match[0]])) { $mapping[$match[0]] = is_array($mapping[$match[0]]) ? $mapping[$match[0]] : [$mapping[$match[0]]]; $mapping[$match[0]][] = \count($mapping); - } else { $mapping[$match[0]] = \count($mapping); } diff --git a/src/Sqlsrv/SqlsrvStatement.php b/src/Sqlsrv/SqlsrvStatement.php index 01b73e43..9bff16df 100644 --- a/src/Sqlsrv/SqlsrvStatement.php +++ b/src/Sqlsrv/SqlsrvStatement.php @@ -205,7 +205,6 @@ public function prepareParameterKeyMapping($sql) if (isset($mapping[$match[0]])) { $mapping[$match[0]] = is_array($mapping[$match[0]]) ? $mapping[$match[0]] : [$mapping[$match[0]]]; $mapping[$match[0]][] = \count($mapping); - } else { $mapping[$match[0]] = \count($mapping); } From 823a480913064cdb441477333a0268afea19c9fd Mon Sep 17 00:00:00 2001 From: Harald Leithner Date: Sun, 16 Jun 2024 11:23:19 +0200 Subject: [PATCH 2/2] Try to cleanup failing tests --- Tests/Pgsql/PgsqlPreparedStatementTest.php | 14 +++++++------- Tests/Sqlsrv/SqlsrvPreparedStatementTest.php | 16 ++++++++-------- Tests/Sqlsrv/SqlsrvStatementTest.php | 2 +- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Tests/Pgsql/PgsqlPreparedStatementTest.php b/Tests/Pgsql/PgsqlPreparedStatementTest.php index f2177f17..17dd43e9 100644 --- a/Tests/Pgsql/PgsqlPreparedStatementTest.php +++ b/Tests/Pgsql/PgsqlPreparedStatementTest.php @@ -10,6 +10,9 @@ use Joomla\Database\Exception\ExecutionFailureException; use Joomla\Test\DatabaseTestCase; +/** + * Test class for Joomla\Database\Pgsql\PgsqlStatement + */ class PgsqlPreparedStatementTest extends DatabaseTestCase { /** @@ -19,14 +22,11 @@ class PgsqlPreparedStatementTest extends DatabaseTestCase */ public static function setUpBeforeClass(): void { - $manager = static::getDatabaseManager(); + parent::setUpBeforeClass(); - $connection = $manager->getConnection(); - $manager->dropDatabase(); - $manager->createDatabase(); - $connection->select($manager->getDbName()); - - static::$connection = $connection; + if (!static::$connection || static::$connection->getName() !== 'pgsql') { + self::markTestSkipped('PostgreSQL database not configured.'); + } } /** diff --git a/Tests/Sqlsrv/SqlsrvPreparedStatementTest.php b/Tests/Sqlsrv/SqlsrvPreparedStatementTest.php index 2a48b1d5..6afd8706 100644 --- a/Tests/Sqlsrv/SqlsrvPreparedStatementTest.php +++ b/Tests/Sqlsrv/SqlsrvPreparedStatementTest.php @@ -11,6 +11,9 @@ use Joomla\Database\Sqlsrv\SqlsrvStatement; use Joomla\Test\DatabaseTestCase; +/** + * Test class for Joomla\Database\Sqlsrv\SqlsrvStatement + */ class SqlsrvPreparedStatementTest extends DatabaseTestCase { /** @@ -20,14 +23,11 @@ class SqlsrvPreparedStatementTest extends DatabaseTestCase */ public static function setUpBeforeClass(): void { - $manager = static::getDatabaseManager(); + parent::setUpBeforeClass(); - $connection = $manager->getConnection(); - $manager->dropDatabase(); - $manager->createDatabase(); - $connection->select($manager->getDbName()); - - static::$connection = $connection; + if (!static::$connection || static::$connection->getName() !== 'sqlsrv') { + self::markTestSkipped('SQL Server database not configured.'); + } } /** @@ -49,7 +49,7 @@ protected function setUp(): void } catch (ExecutionFailureException $exception) { $this->markTestSkipped( \sprintf( - 'Could not load MS SQL Server database: %s', + 'Could not load SQL Server database: %s', $exception->getMessage() ) ); diff --git a/Tests/Sqlsrv/SqlsrvStatementTest.php b/Tests/Sqlsrv/SqlsrvStatementTest.php index 5803f777..07b449f1 100644 --- a/Tests/Sqlsrv/SqlsrvStatementTest.php +++ b/Tests/Sqlsrv/SqlsrvStatementTest.php @@ -4,7 +4,7 @@ * @license GNU General Public License version 2 or later; see LICENSE */ -namespace Joomla\Database\Tests\Sqlqrv; +namespace Joomla\Database\Tests\Sqlsrv; use Joomla\Database\DatabaseDriver; use Joomla\Database\Exception\ExecutionFailureException;