Commit 7bd866aa authored by alexpott's avatar alexpott
Browse files

Revert "Issue #2505521 by benjy: Clean-up un-need test classes in migrate_drupal"

This reverts commit 37001445.
parent ff7fc0fd
......@@ -24,11 +24,6 @@ function config_help($route_name, RouteMatchInterface $route_match) {
$output = '';
$output .= '<p>' . t('Import configuration that is placed in your staging directory. All changes, deletions, renames, and additions are listed below.') . '</p>';
return $output;
case 'config.import_full':
$output = '';
$output .= '<p>' . t('After uploading a configuration archive, you will be able to examine the changes and import them.') . '</p>';
return $output;
}
}
......
......@@ -55,10 +55,13 @@ public function getFormId() {
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$form['description'] = array(
'#markup' => '<p>' . $this->t('Use the upload button below.') . '</p>',
);
$form['import_tarball'] = array(
'#type' => 'file',
'#title' => $this->t('Configuration archive'),
'#description' => $this->t('Allowed types: @extensions.', array('@extensions' => 'tar.gz tgz')),
'#title' => $this->t('Select your configuration export file'),
'#description' => $this->t('This form will redirect you to the import configuration screen.'),
);
$form['submit'] = array(
......@@ -77,7 +80,7 @@ public function validateForm(array &$form, FormStateInterface $form_state) {
$form_state->setValue('import_tarball', $file_upload->getRealPath());
}
else {
$form_state->setErrorByName('import_tarball', $this->t('The file could not be uploaded.'));
$form_state->setErrorByName('import_tarball', $this->t('The import tarball could not be uploaded.'));
}
}
......@@ -94,7 +97,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) {
$files[] = $file['filename'];
}
$archiver->extractList($files, config_get_config_directory(CONFIG_STAGING_DIRECTORY));
drupal_set_message($this->t('Your configuration files were successfully uploaded and are ready for import.'));
drupal_set_message($this->t('Your configuration files were successfully uploaded, ready for import.'));
$form_state->setRedirect('config.sync');
}
catch (\Exception $e) {
......
......@@ -76,22 +76,11 @@ protected function setUp() {
$migration->expects($this->any())
->method('getHighWater')
->will($this->returnValue(static::ORIGINAL_HIGH_WATER));
// Setup the plugin.
$plugin_class = static::PLUGIN_CLASS;
// Need the test class, not the original because we need a setDatabase method. This is not pretty :/
$plugin_class = preg_replace('/^Drupal\\\\(\w+)\\\\Plugin\\\\migrate(\\\\source(\\\\.+)?\\\\)([^\\\\]+)$/', 'Drupal\\Tests\\\$1\\Unit$2Test$4', static::PLUGIN_CLASS);
$plugin = new $plugin_class($this->migrationConfiguration['source'], $this->migrationConfiguration['source']['plugin'], array(), $migration, $entity_manager);
// Do some reflection to set the database and moduleHandler.
$plugin_reflection = new \ReflectionClass($plugin);
$database_property = $plugin_reflection->getProperty('database');
$database_property->setAccessible(TRUE);
$module_handler_property = $plugin_reflection->getProperty('moduleHandler');
$module_handler_property->setAccessible(TRUE);
// Set the database and the module handler onto our plugin.
$database_property->setValue($plugin, $this->getDatabase($this->databaseContents + array('test_map' => array())));
$module_handler_property->setValue($plugin, $module_handler);
$plugin->setDatabase($this->getDatabase($this->databaseContents + array('test_map' => array())));
$plugin->setModuleHandler($module_handler);
$plugin->setStringTranslation($this->getStringTranslationStub());
$migration->expects($this->any())
->method('getSourcePlugin')
......
......@@ -44,3 +44,17 @@ abstract class VariableMultiRowTestBase extends MigrateSqlSourceTestCase {
);
}
namespace Drupal\Tests\migrate_drupal\Unit\source;
use Drupal\Core\Database\Connection;
use Drupal\Core\Extension\ModuleHandlerInterface;
class TestVariableMultiRow extends \Drupal\migrate_drupal\Plugin\migrate\source\VariableMultiRow {
public function setDatabase(Connection $database) {
$this->database = $database;
}
public function setModuleHandler(ModuleHandlerInterface $module_handler) {
$this->moduleHandler = $module_handler;
}
}
......@@ -46,3 +46,17 @@ class VariableTest extends MigrateSqlSourceTestCase {
);
}
namespace Drupal\Tests\migrate_drupal\Unit\source;
use Drupal\Core\Database\Connection;
use Drupal\Core\Extension\ModuleHandlerInterface;
class TestVariable extends \Drupal\migrate_drupal\Plugin\migrate\source\Variable {
public function setDatabase(Connection $database) {
$this->database = $database;
}
public function setModuleHandler(ModuleHandlerInterface $module_handler) {
$this->moduleHandler = $module_handler;
}
}
......@@ -73,3 +73,18 @@ protected function setUp() {
}
}
namespace Drupal\Tests\migrate_drupal\Unit\source\d6;
use Drupal\Core\Database\Connection;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\migrate_drupal\Plugin\migrate\source\d6\Action;
class TestAction extends Action {
public function setDatabase(Connection $database) {
$this->database = $database;
}
public function setModuleHandler(ModuleHandlerInterface $module_handler) {
$this->moduleHandler = $module_handler;
}
}
......@@ -66,3 +66,20 @@ protected function setUp() {
}
}
namespace Drupal\Tests\migrate_drupal\Unit\source\d6;
use Drupal\Core\Database\Connection;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\migrate_drupal\Plugin\migrate\source\d6\AggregatorFeed;
class TestAggregatorFeed extends AggregatorFeed {
public function setDatabase(Connection $database) {
$this->database = $database;
}
public function setModuleHandler(ModuleHandlerInterface $module_handler) {
$this->moduleHandler = $module_handler;
}
}
......@@ -55,3 +55,20 @@ class AggregatorItemTest extends MigrateSqlSourceTestCase {
));
}
namespace Drupal\Tests\migrate_drupal\Unit\source\d6;
use Drupal\Core\Database\Connection;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\migrate_drupal\Plugin\migrate\source\d6\AggregatorItem;
class TestAggregatorItem extends AggregatorItem {
public function setDatabase(Connection $database) {
$this->database = $database;
}
public function setModuleHandler(ModuleHandlerInterface $module_handler) {
$this->moduleHandler = $module_handler;
}
}
......@@ -83,3 +83,18 @@ protected function setUp() {
}
}
namespace Drupal\Tests\migrate_drupal\Unit\source\d6;
use Drupal\Core\Database\Connection;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\migrate_drupal\Plugin\migrate\source\d6\Block;
class TestBlock extends Block {
public function setDatabase(Connection $database) {
$this->database = $database;
}
public function setModuleHandler(ModuleHandlerInterface $module_handler) {
$this->moduleHandler = $module_handler;
}
}
......@@ -57,3 +57,18 @@ protected function setUp() {
}
}
namespace Drupal\Tests\migrate_drupal\Unit\source\d6;
use Drupal\Core\Database\Connection;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\migrate_drupal\Plugin\migrate\source\d6\Box;
class TestBox extends Box {
public function setDatabase(Connection $database) {
$this->database = $database;
}
public function setModuleHandler(ModuleHandlerInterface $module_handler) {
$this->moduleHandler = $module_handler;
}
}
......@@ -57,3 +57,18 @@ protected function setUp() {
}
}
namespace Drupal\Tests\migrate_drupal\Unit\source\d6;
use Drupal\Core\Database\Connection;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\migrate_drupal\Plugin\migrate\source\d6\ContactCategory;
class TestContactCategory extends ContactCategory {
public function setDatabase(Connection $database) {
$this->database = $database;
}
public function setModuleHandler(ModuleHandlerInterface $module_handler) {
$this->moduleHandler = $module_handler;
}
}
......@@ -106,3 +106,16 @@ protected function setUp() {
}
}
use Drupal\Core\Database\Connection;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\migrate_drupal\Plugin\migrate\source\d6\FieldInstancePerViewMode;
class TestFieldInstancePerViewMode extends FieldInstancePerViewMode {
public function setDatabase(Connection $database) {
$this->database = $database;
}
public function setModuleHandler(ModuleHandlerInterface $module_handler) {
$this->moduleHandler = $module_handler;
}
}
......@@ -96,3 +96,17 @@ protected function setUp() {
}
}
namespace Drupal\Tests\migrate_drupal\Unit\source\d6;
use Drupal\Core\Database\Connection;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\migrate_drupal\Plugin\migrate\source\d6\FieldInstance;
class TestFieldInstance extends FieldInstance {
public function setDatabase(Connection $database) {
$this->database = $database;
}
public function setModuleHandler(ModuleHandlerInterface $module_handler) {
$this->moduleHandler = $module_handler;
}
}
......@@ -78,3 +78,19 @@ protected function setUp() {
}
}
namespace Drupal\Tests\migrate_drupal\Unit\source\d6;
use Drupal\Core\Database\Connection;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\migrate_drupal\Plugin\migrate\source\d6\Field;
class TestField extends Field {
public function setDatabase(Connection $database) {
$this->database = $database;
}
public function setModuleHandler(ModuleHandlerInterface $module_handler) {
$this->moduleHandler = $module_handler;
}
}
......@@ -61,3 +61,18 @@ protected function setUp() {
}
}
namespace Drupal\Tests\migrate_drupal\Unit\source\d6;
use Drupal\Core\Database\Connection;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\migrate_drupal\Plugin\migrate\source\d6\File;
class TestFile extends File {
public function setDatabase(Connection $database) {
$this->database = $database;
}
public function setModuleHandler(ModuleHandlerInterface $module_handler) {
$this->moduleHandler = $module_handler;
}
}
......@@ -112,3 +112,18 @@ protected function setUp() {
parent::setUp();
}
}
namespace Drupal\Tests\migrate_drupal\Unit\source\d6;
use Drupal\Core\Database\Connection;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\migrate_drupal\Plugin\migrate\source\d6\FilterFormat;
class TestFilterFormat extends FilterFormat {
public function setDatabase(Connection $database) {
$this->database = $database;
}
public function setModuleHandler(ModuleHandlerInterface $module_handler) {
$this->moduleHandler = $module_handler;
}
}
......@@ -116,3 +116,18 @@ public function setUp() {
}
}
namespace Drupal\Tests\migrate_drupal\Unit\source\d6;
use Drupal\Core\Database\Connection;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\migrate_drupal\Plugin\migrate\source\d6\MenuLink;
class TestMenuLink extends MenuLink {
public function setDatabase(Connection $database) {
$this->database = $database;
}
public function setModuleHandler(ModuleHandlerInterface $module_handler) {
$this->moduleHandler = $module_handler;
}
}
......@@ -60,3 +60,18 @@ protected function setUp() {
}
}
namespace Drupal\Tests\migrate_drupal\Unit\source\d6;
use Drupal\Core\Database\Connection;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\migrate_drupal\Plugin\migrate\source\d6\Menu;
class TestMenu extends Menu {
public function setDatabase(Connection $database) {
$this->database = $database;
}
public function setModuleHandler(ModuleHandlerInterface $module_handler) {
$this->moduleHandler = $module_handler;
}
}
......@@ -75,3 +75,18 @@ protected function setUp() {
}
}
namespace Drupal\Tests\migrate_drupal\Unit\source\d6;
use Drupal\Core\Database\Connection;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\migrate_drupal\Plugin\migrate\source\d6\NodeType;
class TestNodeType extends NodeType {
public function setDatabase(Connection $database) {
$this->database = $database;
}
public function setModuleHandler(ModuleHandlerInterface $module_handler) {
$this->moduleHandler = $module_handler;
}
}
......@@ -94,3 +94,18 @@ protected function setUp() {
}
}
namespace Drupal\Tests\migrate_drupal\Unit\source\d6;
use Drupal\Core\Database\Connection;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\migrate_drupal\Plugin\migrate\source\d6\ProfileField;
class TestProfileField extends ProfileField {
public function setDatabase(Connection $database) {
$this->database = $database;
}
public function setModuleHandler(ModuleHandlerInterface $module_handler) {
$this->moduleHandler = $module_handler;
}
}
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