Skip to content

Commit 58c2276

Browse files
committed
Skipped tests when PDO is not available
1 parent f7c5bf1 commit 58c2276

File tree

6 files changed

+30
-6
lines changed

6 files changed

+30
-6
lines changed

tests/Symfony/Tests/Bridge/Doctrine/DoctrineOrmTestCase.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ protected function setUp()
3030
*/
3131
static public function createTestEntityManager($paths = array())
3232
{
33+
if (!class_exists('PDO') || !in_array('sqlite', \PDO::getAvailableDrivers())) {
34+
self::markTestSkipped('This test requires SQLite support in your environment');
35+
}
3336
$config = new \Doctrine\ORM\Configuration();
3437
$config->setAutoGenerateProxyClasses(true);
3538
$config->setProxyDir(\sys_get_temp_dir());

tests/Symfony/Tests/Component/HttpKernel/Profiler/ProfilerTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ class ProfilerTest extends \PHPUnit_Framework_TestCase
2121
{
2222
public function testCollect()
2323
{
24+
if (!class_exists('SQLite3') && (!class_exists('PDO') || !in_array('sqlite', \PDO::getAvailableDrivers()))) {
25+
$this->markTestSkipped('This test requires SQLite support in your environment');
26+
}
27+
2428
$request = new Request();
2529
$request->query->set('foo', 'bar');
2630
$response = new Response();

tests/Symfony/Tests/Component/HttpKernel/Profiler/SqliteProfilerStorageTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ public static function tearDownAfterClass()
3535

3636
protected function setUp()
3737
{
38+
if (!class_exists('SQLite3') && (!class_exists('PDO') || !in_array('sqlite', \PDO::getAvailableDrivers()))) {
39+
$this->markTestSkipped('This test requires SQLite support in your environment');
40+
}
3841
self::$storage->purge();
3942
}
4043

tests/Symfony/Tests/Component/Security/Acl/Dbal/AclProviderBenchmarkTest.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
*/
2323
class AclProviderBenchmarkTest extends \PHPUnit_Framework_TestCase
2424
{
25+
/** @var \Doctrine\DBAL\Connection */
2526
protected $con;
2627
protected $insertClassStmt;
2728
protected $insertSidStmt;
@@ -31,12 +32,17 @@ class AclProviderBenchmarkTest extends \PHPUnit_Framework_TestCase
3132

3233
protected function setUp()
3334
{
34-
$this->con = DriverManager::getConnection(array(
35-
'driver' => 'pdo_mysql',
36-
'host' => 'localhost',
37-
'user' => 'root',
38-
'dbname' => 'testdb',
39-
));
35+
try {
36+
$this->con = DriverManager::getConnection(array(
37+
'driver' => 'pdo_mysql',
38+
'host' => 'localhost',
39+
'user' => 'root',
40+
'dbname' => 'testdb',
41+
));
42+
$this->con->connect();
43+
} catch (\Exception $e) {
44+
$this->markTestSkipped('Unable to connect to the database: '.$e->getMessage());
45+
}
4046
}
4147

4248
protected function tearDown()

tests/Symfony/Tests/Component/Security/Acl/Dbal/AclProviderTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,10 @@ protected function setUp()
127127
if (!class_exists('Doctrine\DBAL\DriverManager')) {
128128
$this->markTestSkipped('The Doctrine2 DBAL is required for this test');
129129
}
130+
if (!class_exists('PDO') || !in_array('sqlite', \PDO::getAvailableDrivers())) {
131+
self::markTestSkipped('This test requires SQLite support in your environment');
132+
}
133+
130134
$this->con = DriverManager::getConnection(array(
131135
'driver' => 'pdo_sqlite',
132136
'memory' => true,

tests/Symfony/Tests/Component/Security/Acl/Dbal/MutableAclProviderTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,10 @@ protected function setUp()
432432
if (!class_exists('Doctrine\DBAL\DriverManager')) {
433433
$this->markTestSkipped('The Doctrine2 DBAL is required for this test');
434434
}
435+
if (!class_exists('PDO') || !in_array('sqlite', \PDO::getAvailableDrivers())) {
436+
self::markTestSkipped('This test requires SQLite support in your environment');
437+
}
438+
435439
$this->con = DriverManager::getConnection(array(
436440
'driver' => 'pdo_sqlite',
437441
'memory' => true,

0 commit comments

Comments
 (0)