Skip to content

Commit eba3e50

Browse files
authored
Merge pull request phpbb#6892 from rubencm/ticket/17573
[ticket/17573] Skip tests when dbms is null
2 parents 133fa26 + d9788b0 commit eba3e50

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

tests/migrator/schema_generator_test.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,15 @@ protected function setUp(): void
5757

5858
$this->config = new \phpbb\config\config(array());
5959
$this->db = new \phpbb\db\driver\sqlite3();
60-
$this->doctrine_db = \phpbb\db\doctrine\connection_factory::get_connection(new phpbb_mock_config_php_file());
60+
// Some local setups may not configure a DB driver. If the configured
61+
// 'dbms' is null, skip this test instead of failing with a TypeError in
62+
// the connection factory which expects a non-null driver name.
63+
$mock_config = new phpbb_mock_config_php_file();
64+
if ($mock_config->get('dbms') === null)
65+
{
66+
self::markTestSkipped('Skipping schema generator tests: dbms is not configured (null) in local environment.');
67+
}
68+
$this->doctrine_db = \phpbb\db\doctrine\connection_factory::get_connection($mock_config);
6169
$factory = new \phpbb\db\tools\factory();
6270
$this->db_tools = $factory->get($this->doctrine_db);
6371
$this->db_tools->set_table_prefix($this->table_prefix);

tests/test_framework/phpbb_database_test_case.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,15 @@ public static function setUpBeforeClass(): void
6666
global $table_prefix;
6767

6868
$db = new \phpbb\db\driver\sqlite3();
69-
$doctrine = \phpbb\db\doctrine\connection_factory::get_connection(new phpbb_mock_config_php_file());
69+
// Some local setups may not configure a DB driver. If the configured
70+
// 'dbms' is null, skip this test instead of failing with a TypeError in
71+
// the connection factory which expects a non-null driver name.
72+
$mock_config = new phpbb_mock_config_php_file();
73+
if ($mock_config->get('dbms') === null)
74+
{
75+
self::markTestSkipped('Skipping schema generator tests: dbms is not configured (null) in local environment.');
76+
}
77+
$doctrine = \phpbb\db\doctrine\connection_factory::get_connection($mock_config);
7078
$factory = new \phpbb\db\tools\factory();
7179
$db_tools = $factory->get($doctrine, true);
7280
$db_tools->set_table_prefix($table_prefix);

0 commit comments

Comments
 (0)