Skip to content

Commit 2d5c972

Browse files
committed
Check support in setup
1 parent 0be0f74 commit 2d5c972

File tree

6 files changed

+47
-0
lines changed

6 files changed

+47
-0
lines changed

Tests/DatabaseMysqlCase.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
namespace Joomla\Database\Tests;
88

9+
use Joomla\Database\Mysql\MysqlDriver;
910
use Joomla\Test\TestDatabase;
1011
use Joomla\Database\DatabaseDriver;
1112

@@ -43,6 +44,12 @@ public static function setUpBeforeClass()
4344
return;
4445
}
4546

47+
// Make sure the driver is supported
48+
if (!MysqlDriver::isSupported())
49+
{
50+
static::skip('The PDO MySQL driver is not supported on this platform.');
51+
}
52+
4653
// First let's trim the mysql: part off the front of the DSN if it exists.
4754
if (strpos($dsn, 'mysql:') === 0)
4855
{

Tests/DatabaseMysqliCase.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
namespace Joomla\Database\Tests;
88

9+
use Joomla\Database\Mysql\MysqlDriver;
10+
use Joomla\Database\Mysqli\MysqliDriver;
911
use Joomla\Test\TestDatabase;
1012
use Joomla\Database\DatabaseDriver;
1113

@@ -43,6 +45,12 @@ public static function setUpBeforeClass()
4345
return;
4446
}
4547

48+
// Make sure the driver is supported, we check both PDO MySQL and MySQLi here due to PHPUnit requiring a PDO connection to set up the test
49+
if (!MysqlDriver::isSupported() || !MysqliDriver::isSupported())
50+
{
51+
static::skip('The PDO MySQL or MySQLi driver is not supported on this platform.');
52+
}
53+
4654
// First let's trim the mysql: part off the front of the DSN if it exists.
4755
if (strpos($dsn, 'mysql:') === 0)
4856
{

Tests/DatabaseOracleCase.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
namespace Joomla\Database\Tests;
88

9+
use Joomla\Database\Oracle\OracleDriver;
910
use Joomla\Test\TestDatabase;
1011
use Joomla\Database\DatabaseDriver;
1112

@@ -43,6 +44,12 @@ public static function setUpBeforeClass()
4344
return;
4445
}
4546

47+
// Make sure the driver is supported
48+
if (!OracleDriver::isSupported())
49+
{
50+
static::skip('The PDO Oracle driver is not supported on this platform.');
51+
}
52+
4653
// First let's trim the oci: part off the front of the DSN if it exists.
4754
if (strpos($dsn, 'oci:') === 0)
4855
{

Tests/DatabasePgsqlCase.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
namespace Joomla\Database\Tests;
88

9+
use Joomla\Database\Pgsql\PgsqlDriver;
910
use Joomla\Test\TestDatabase;
1011
use Joomla\Database\DatabaseDriver;
1112

@@ -43,6 +44,12 @@ public static function setUpBeforeClass()
4344
return;
4445
}
4546

47+
// Make sure the driver is supported
48+
if (!PgsqlDriver::isSupported())
49+
{
50+
static::skip('The PDO PostgreSQL driver is not supported on this platform.');
51+
}
52+
4653
// First let's trim the pgsql: part off the front of the DSN if it exists.
4754
if (strpos($dsn, 'pgsql:') === 0)
4855
{

Tests/DatabasePostgresqlCase.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
namespace Joomla\Database\Tests;
88

9+
use Joomla\Database\Pgsql\PgsqlDriver;
10+
use Joomla\Database\Postgresql\PostgresqlDriver;
911
use Joomla\Test\TestDatabase;
1012
use Joomla\Database\DatabaseDriver;
1113

@@ -43,6 +45,15 @@ public static function setUpBeforeClass()
4345
return;
4446
}
4547

48+
/*
49+
* Make sure the driver is supported, we check both PDO PostgreSQL and "plain" PostgreSQL here
50+
* due to PHPUnit requiring a PDO connection to set up the test
51+
*/
52+
if (!PostgresqlDriver::isSupported() || !PgsqlDriver::isSupported())
53+
{
54+
static::skip('The PDO PostgreSQL or PostgreSQL driver is not supported on this platform.');
55+
}
56+
4657
// First let's trim the pgsql: part off the front of the DSN if it exists.
4758
if (strpos($dsn, 'pgsql:') === 0)
4859
{

Tests/DatabaseSqlsrvCase.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
namespace Joomla\Database\Tests;
88

9+
use Joomla\Database\Sqlsrv\SqlsrvDriver;
910
use Joomla\Test\TestDatabase;
1011
use Joomla\Database\DatabaseDriver;
1112

@@ -43,6 +44,12 @@ public static function setUpBeforeClass()
4344
return;
4445
}
4546

47+
// Make sure the driver is supported
48+
if (!SqlsrvDriver::isSupported())
49+
{
50+
static::skip('The SQL Server driver is not supported on this platform.');
51+
}
52+
4653
// First let's trim the sqlsrv: part off the front of the DSN if it exists.
4754
if (strpos($dsn, 'sqlsrv:') === 0)
4855
{

0 commit comments

Comments
 (0)