Commit 978fcf0c authored by alexpott's avatar alexpott

Issue #2534158 by phenaproxima, mikeryan: MigrateFullDrupalTestBase must use dynamic test discovery

parent 97eb1cf1
......@@ -7,7 +7,6 @@
namespace Drupal\migrate_drupal\Tests;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\migrate\MigrateExecutable;
use Drupal\simpletest\TestBase;
......@@ -16,6 +15,19 @@
*/
abstract class MigrateFullDrupalTestBase extends MigrateDrupalTestBase {
/**
* The test class which discovered migration tests must extend in order to be
* included in this test run.
*/
const BASE_TEST_CLASS = 'Drupal\migrate_drupal\Tests\MigrateDrupalTestBase';
/**
* A list of fully-qualified test classes which should be ignored.
*
* @var string[]
*/
protected static $blacklist = [];
/**
* Get the dump classes required for this migration test.
*
......@@ -28,9 +40,24 @@ abstract class MigrateFullDrupalTestBase extends MigrateDrupalTestBase {
* Get the test classes that needs to be run for this test.
*
* @return array
* The list of test fully-classified class names.
* The list of fully-classified test class names.
*/
protected abstract function getTestClassesList();
protected function getTestClassesList() {
$classes = [];
$discovery = \Drupal::getContainer()->get('test_discovery');
foreach (static::$modules as $module) {
foreach ($discovery->getTestClasses($module) as $group) {
foreach (array_keys($group) as $class) {
if (is_subclass_of($class, static::BASE_TEST_CLASS)) {
$classes[] = $class;
}
}
}
}
// Exclude blacklisted classes.
return array_diff($classes, static::$blacklist);
}
/**
* {@inheritdoc}
......
......@@ -17,6 +17,12 @@
*/
class MigrateDrupal6Test extends MigrateFullDrupalTestBase {
const BASE_TEST_CLASS = 'Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase';
protected static $blacklist = array(
'Drupal\migrate_drupal\Tests\dependencies\MigrateDependenciesTest',
);
/**
* Modules to enable.
*
......@@ -43,6 +49,7 @@ class MigrateDrupal6Test extends MigrateFullDrupalTestBase {
'locale',
'menu_link_content',
'menu_ui',
'migrate_drupal',
'node',
'options',
'search',
......@@ -248,101 +255,6 @@ protected function getDumps() {
);
}
/**
* {@inheritdoc}
*/
protected function getTestClassesList() {
$classes = array(
__NAMESPACE__ . '\MigrateActionConfigsTest',
__NAMESPACE__ . '\MigrateAggregatorConfigsTest',
__NAMESPACE__ . '\MigrateAggregatorFeedTest',
__NAMESPACE__ . '\MigrateAggregatorItemTest',
__NAMESPACE__ . '\MigrateBlockTest',
__NAMESPACE__ . '\MigrateBookTest',
__NAMESPACE__ . '\MigrateBookConfigsTest',
__NAMESPACE__ . '\MigrateCckFieldValuesTest',
__NAMESPACE__ . '\MigrateCckFieldRevisionTest',
__NAMESPACE__ . '\MigrateCommentTypeTest',
__NAMESPACE__ . '\MigrateCommentTest',
__NAMESPACE__ . '\MigrateCommentVariableEntityDisplayTest',
__NAMESPACE__ . '\MigrateCommentVariableEntityFormDisplayTest',
__NAMESPACE__ . '\MigrateCommentVariableEntityFormDisplaySubjectTest',
__NAMESPACE__ . '\MigrateCommentVariableFieldTest',
__NAMESPACE__ . '\MigrateCommentVariableInstanceTest',
__NAMESPACE__ . '\MigrateContactCategoryTest',
__NAMESPACE__ . '\MigrateContactConfigsTest',
__NAMESPACE__ . '\MigrateBlockContentTest',
__NAMESPACE__ . '\MigrateDateFormatTest',
__NAMESPACE__ . '\MigrateDblogConfigsTest',
__NAMESPACE__ . '\MigrateFieldTest',
__NAMESPACE__ . '\MigrateFieldInstanceTest',
__NAMESPACE__ . '\MigrateFieldFormatterSettingsTest',
__NAMESPACE__ . '\MigrateFieldWidgetSettingsTest',
__NAMESPACE__ . '\MigrateFileConfigsTest',
__NAMESPACE__ . '\MigrateFileTest',
__NAMESPACE__ . '\MigrateFilterFormatTest',
__NAMESPACE__ . '\MigrateForumConfigsTest',
__NAMESPACE__ . '\MigrateLocaleConfigsTest',
__NAMESPACE__ . '\MigrateMenuConfigsTest',
__NAMESPACE__ . '\MigrateMenuLinkTest',
__NAMESPACE__ . '\MigrateMenuTest',
__NAMESPACE__ . '\MigrateNodeBundleSettingsTest',
__NAMESPACE__ . '\MigrateNodeConfigsTest',
__NAMESPACE__ . '\MigrateNodeRevisionTest',
__NAMESPACE__ . '\MigrateNodeTest',
__NAMESPACE__ . '\MigrateNodeTypeTest',
__NAMESPACE__ . '\MigrateUserProfileValuesTest',
__NAMESPACE__ . '\MigrateSearchConfigsTest',
__NAMESPACE__ . '\MigrateSearchPageTest',
__NAMESPACE__ . '\MigrateSimpletestConfigsTest',
__NAMESPACE__ . '\MigrateStatisticsConfigsTest',
__NAMESPACE__ . '\MigrateSyslogConfigsTest',
__NAMESPACE__ . '\MigrateSystemCronTest',
__NAMESPACE__ . '\MigrateSystemFileTest',
__NAMESPACE__ . '\MigrateSystemFilterTest',
__NAMESPACE__ . '\MigrateSystemImageGdTest',
__NAMESPACE__ . '\MigrateSystemImageTest',
__NAMESPACE__ . '\MigrateSystemLoggingTest',
__NAMESPACE__ . '\MigrateSystemMaintenanceTest',
__NAMESPACE__ . '\MigrateSystemPerformanceTest',
__NAMESPACE__ . '\MigrateSystemRssTest',
__NAMESPACE__ . '\MigrateSystemSiteTest',
__NAMESPACE__ . '\MigrateTaxonomyConfigsTest',
__NAMESPACE__ . '\MigrateTaxonomyTermTest',
__NAMESPACE__ . '\MigrateTaxonomyVocabularyTest',
__NAMESPACE__ . '\MigrateTermNodeRevisionTest',
__NAMESPACE__ . '\MigrateTermNodeTest',
__NAMESPACE__ . '\MigrateTextConfigsTest',
__NAMESPACE__ . '\MigrateUpdateConfigsTest',
__NAMESPACE__ . '\MigrateUploadEntityDisplayTest',
__NAMESPACE__ . '\MigrateUploadEntityFormDisplayTest',
__NAMESPACE__ . '\MigrateUploadFieldTest',
__NAMESPACE__ . '\MigrateUploadInstanceTest',
__NAMESPACE__ . '\MigrateUploadTest',
__NAMESPACE__ . '\MigrateUrlAliasTest',
__NAMESPACE__ . '\MigrateUserConfigsTest',
__NAMESPACE__ . '\MigrateUserContactSettingsTest',
__NAMESPACE__ . '\MigrateUserProfileEntityDisplayTest',
__NAMESPACE__ . '\MigrateUserProfileEntityFormDisplayTest',
__NAMESPACE__ . '\MigrateUserProfileFieldTest',
__NAMESPACE__ . '\MigrateUserProfileFieldInstanceTest',
__NAMESPACE__ . '\MigrateUserPictureEntityDisplayTest',
__NAMESPACE__ . '\MigrateUserPictureEntityFormDisplayTest',
__NAMESPACE__ . '\MigrateUserPictureFileTest',
__NAMESPACE__ . '\MigrateUserPictureFieldTest',
__NAMESPACE__ . '\MigrateUserPictureInstanceTest',
__NAMESPACE__ . '\MigrateUserRoleTest',
__NAMESPACE__ . '\MigrateUserTest',
__NAMESPACE__ . '\MigrateViewModesTest',
__NAMESPACE__ . '\MigrateVocabularyEntityDisplayTest',
__NAMESPACE__ . '\MigrateVocabularyEntityFormDisplayTest',
__NAMESPACE__ . '\MigrateVocabularyFieldInstanceTest',
__NAMESPACE__ . '\MigrateVocabularyFieldTest',
);
return $classes;
}
/**
* Returns the path to the dump directory.
*
......
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