Commit 2fdc2ea2 authored by alexpott's avatar alexpott

Issue #2554185 by mikeker, Mile23: Tests should skip if they don't have a dependency, not fail

parent 0b5b1f13
...@@ -406,17 +406,17 @@ protected function config($name) { ...@@ -406,17 +406,17 @@ protected function config($name) {
protected function getDatabaseConnectionInfo() { protected function getDatabaseConnectionInfo() {
// If the test is run with argument dburl then use it. // If the test is run with argument dburl then use it.
$db_url = getenv('SIMPLETEST_DB'); $db_url = getenv('SIMPLETEST_DB');
if (!empty($db_url)) { if (empty($db_url)) {
$this->markTestSkipped('There is no database connection so no tests can be run. You must provide a SIMPLETEST_DB environment variable to run PHPUnit based functional tests outside of run-tests.sh. See https://www.drupal.org/node/2116263#skipped-tests for more information.');
}
else {
$database = Database::convertDbUrlToConnectionInfo($db_url, $this->root); $database = Database::convertDbUrlToConnectionInfo($db_url, $this->root);
Database::addConnectionInfo('default', 'default', $database); Database::addConnectionInfo('default', 'default', $database);
} }
// Clone the current connection and replace the current prefix. // Clone the current connection and replace the current prefix.
$connection_info = Database::getConnectionInfo('default'); $connection_info = Database::getConnectionInfo('default');
if (is_null($connection_info)) { if (!empty($connection_info)) {
throw new \InvalidArgumentException('There is no database connection so no tests can be run. You must provide a SIMPLETEST_DB environment variable, like "sqlite://localhost//tmp/test.sqlite", to run PHPUnit based functional tests outside of run-tests.sh.');
}
else {
Database::renameConnection('default', 'simpletest_original_default'); Database::renameConnection('default', 'simpletest_original_default');
foreach ($connection_info as $target => $value) { foreach ($connection_info as $target => $value) {
// Replace the full table prefix definition to ensure that no table // Replace the full table prefix definition to ensure that no table
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment