-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue #3125763 by quietone, heddn, dww, benjifisher, Lal_, Neslee Can…
…il Pinto, alexpott, mikelutz: Hidden dependency on migrate_drupal from node module when only migrate.module is enabled
- Loading branch information
Showing
8 changed files
with
200 additions
and
62 deletions.
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
...rate/tests/modules/migrate_no_migrate_drupal_test/migrate_no_migrate_drupal_test.info.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
name: 'Migrate No Migrate Drupal Test' | ||
type: module | ||
description: Provides fixture for testing without migrate_drupal. | ||
package: Testing | ||
version: VERSION | ||
dependencies: | ||
- drupal:migrate | ||
- drupal:node |
7 changes: 7 additions & 0 deletions
7
...e/tests/modules/migrate_no_migrate_drupal_test/migrate_no_migrate_drupal_test.routing.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
migrate_no_migrate_drupal_test.execute: | ||
path: '/migrate_no_migrate_drupal_test/execute' | ||
defaults: | ||
_controller: '\Drupal\migrate_no_migrate_drupal_test\Controller\ExecuteMigration::execute' | ||
_title: 'Execute' | ||
requirements: | ||
_access: 'TRUE' |
22 changes: 22 additions & 0 deletions
22
...ate/tests/modules/migrate_no_migrate_drupal_test/migrations/node_migration_no_upgrade.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
id: node_migration_no_migrate_drupal | ||
label: Node Migration No Migrate Drupal | ||
source: | ||
plugin: embedded_data | ||
data_rows: | ||
- | ||
id: 1 | ||
nid: 1 | ||
title: Node 1 | ||
- | ||
id: 2 | ||
nid: 2 | ||
title: Node 2 | ||
ids: | ||
id: | ||
type: integer | ||
process: | ||
nid: nid | ||
title: title | ||
destination: | ||
default_bundle: no_migrate_drupal | ||
plugin: entity:node |
45 changes: 45 additions & 0 deletions
45
.../migrate/tests/modules/migrate_no_migrate_drupal_test/src/Controller/ExecuteMigration.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
namespace Drupal\migrate_no_migrate_drupal_test\Controller; | ||
|
||
use Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException; | ||
use Drupal\Core\Controller\ControllerBase; | ||
use Drupal\migrate\MigrateExecutable; | ||
use Drupal\migrate\Plugin\MigrationInterface; | ||
|
||
/** | ||
* Custom controller to execute the test migrations. | ||
* | ||
* This controller class is required for the proper functional testing of | ||
* migration dependencies. Otherwise, the migration directly executed from the | ||
* functional test would use the functional test's class map and autoloader. The | ||
* functional test has all the classes available to it but the controller | ||
* does not. | ||
*/ | ||
class ExecuteMigration extends ControllerBase { | ||
|
||
/** | ||
* Run the node_migration_no_migrate_drupal test migration. | ||
* | ||
* @return array | ||
* A renderable array. | ||
*/ | ||
public function execute() { | ||
$migration_plugin_manager = \Drupal::service('plugin.manager.migration'); | ||
$definitions = $migration_plugin_manager->getDefinitions(); | ||
if ($definitions['node_migration_no_migrate_drupal']['label'] !== 'Node Migration No Migrate Drupal') { | ||
throw new InvalidPluginDefinitionException('node_migration_no_migrate_drupal'); | ||
} | ||
$migrations = $migration_plugin_manager->createInstances(''); | ||
$result = (new MigrateExecutable($migrations['node_migration_no_migrate_drupal']))->import(); | ||
if ($result !== MigrationInterface::RESULT_COMPLETED) { | ||
throw new \RuntimeException('Migration failed'); | ||
} | ||
|
||
return [ | ||
'#type' => 'markup', | ||
'#markup' => 'Migration was successful.', | ||
]; | ||
} | ||
|
||
} |
58 changes: 58 additions & 0 deletions
58
modules/migrate/tests/src/Functional/MigrateNoMigrateDrupalTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?php | ||
|
||
namespace Drupal\Tests\migrate\Functional; | ||
|
||
use Drupal\node\Entity\Node; | ||
use Drupal\Tests\BrowserTestBase; | ||
use Drupal\Tests\node\Traits\ContentTypeCreationTrait; | ||
|
||
/** | ||
* Execute migration. | ||
* | ||
* This is intentionally a Functional test instead of a Kernel test because | ||
* Kernel tests have proven to not catch all edge cases that are encountered | ||
* via a Functional test. | ||
* | ||
* @group migrate | ||
*/ | ||
class MigrateNoMigrateDrupalTest extends BrowserTestBase { | ||
use ContentTypeCreationTrait; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected $defaultTheme = 'stark'; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected static $modules = [ | ||
'migrate', | ||
'migrate_no_migrate_drupal_test', | ||
'node', | ||
]; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected function setUp() { | ||
parent::setUp(); | ||
// Ensures that code from the migrate_drupal module can not be autoloaded | ||
// while testing on DrupalCI. | ||
$this->writeSettings(['settings' => ['deployment_identifier' => (object) ['value' => 'force-new-apcu-key', 'required' => TRUE]]]); | ||
$this->createContentType(['type' => 'no_migrate_drupal']); | ||
} | ||
|
||
/** | ||
* Tests execution of a migration. | ||
*/ | ||
public function testExecutionNoMigrateDrupal() { | ||
$this->drupalGet('/migrate_no_migrate_drupal_test/execute'); | ||
$this->assertSession()->pageTextContains('Migration was successful.'); | ||
$node_1 = Node::load(1); | ||
$node_2 = Node::load(2); | ||
$this->assertEquals('Node 1', $node_1->label()); | ||
$this->assertEquals('Node 2', $node_2->label()); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters