Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
project
drupal
Commits
494f931e
Commit
494f931e
authored
Feb 16, 2018
by
alexpott
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#2945041
by heddn, maxocub: Categorize derived migrations according to their type
parent
1559ab85
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
108 additions
and
30 deletions
+108
-30
core/modules/migrate_drupal/tests/src/Kernel/Plugin/migrate/DestinationCategoryTest.php
...sts/src/Kernel/Plugin/migrate/DestinationCategoryTest.php
+66
-30
core/modules/migrate_drupal/tests/src/Traits/CreateMigrationsTrait.php
...migrate_drupal/tests/src/Traits/CreateMigrationsTrait.php
+33
-0
core/modules/node/migrations/d6_node.yml
core/modules/node/migrations/d6_node.yml
+1
-0
core/modules/node/migrations/d6_node_revision.yml
core/modules/node/migrations/d6_node_revision.yml
+1
-0
core/modules/node/migrations/d6_node_translation.yml
core/modules/node/migrations/d6_node_translation.yml
+1
-0
core/modules/node/migrations/d7_node.yml
core/modules/node/migrations/d7_node.yml
+1
-0
core/modules/node/migrations/d7_node_revision.yml
core/modules/node/migrations/d7_node_revision.yml
+1
-0
core/modules/node/migrations/d7_node_translation.yml
core/modules/node/migrations/d7_node_translation.yml
+1
-0
core/modules/taxonomy/migrations/d6_term_node.yml
core/modules/taxonomy/migrations/d6_term_node.yml
+1
-0
core/modules/taxonomy/migrations/d6_term_node_revision.yml
core/modules/taxonomy/migrations/d6_term_node_revision.yml
+1
-0
core/modules/taxonomy/migrations/d7_taxonomy_term.yml
core/modules/taxonomy/migrations/d7_taxonomy_term.yml
+1
-0
No files found.
core/modules/migrate/tests/src/Kernel/Plugin/DestinationCategoryTest.php
→
core/modules/migrate
_drupal
/tests/src/Kernel/Plugin/
migrate/
DestinationCategoryTest.php
View file @
494f931e
<?php
namespace
Drupal\Tests\migrate\Kernel\Plugin
;
namespace
Drupal\Tests\migrate
_drupal
\Kernel\Plugin
\migrate
;
use
Drupal\ban\Plugin\migrate\destination\BlockedIP
;
use
Drupal\KernelTests\FileSystemModuleDiscoveryDataProviderTrait
;
...
...
@@ -13,18 +13,18 @@
use
Drupal\statistics\Plugin\migrate\destination\NodeCounter
;
use
Drupal\system\Plugin\migrate\destination\d7\ThemeSettings
;
use
Drupal\Tests\migrate_drupal
\
Kernel\MigrateDrupalTestBase
;
use
Drupal\Tests\migrate_drupal
\
Traits\CreateMigrationsTrait
;
use
Drupal\user\Plugin\migrate\destination\UserData
;
/**
* Tests that all migrations are tagged as either content or configuration.
*
* @coversDefaultClass \Drupal\migrate\Plugin\MigrationPluginManager
*
* @group migrate
* @group migrate_drupal
*/
class
DestinationCategoryTest
extends
MigrateDrupalTestBase
{
use
FileSystemModuleDiscoveryDataProviderTrait
;
use
CreateMigrationsTrait
;
/**
* The migration plugin manager.
...
...
@@ -44,33 +44,31 @@ protected function setUp() {
}
/**
*
@covers ::getDefinitions
*
Tests that all D6 migrations are tagged as either Configuration or Content.
*/
public
function
testGetGroupedDefinitions
()
{
$definitions
=
array_keys
(
$this
->
migrationManager
->
getDefinitions
());
public
function
testD6Categories
()
{
$migrations
=
$this
->
drupal6Migrations
();
$this
->
assertArrayHasKey
(
'd6_node:page'
,
$migrations
);
$this
->
assertCategories
(
$migrations
);
}
// Configuration migrations should have a destination plugin that is an
// instance of one of the following classes.
$config_classes
=
[
Config
::
class
,
EntityConfigBase
::
class
,
ThemeSettings
::
class
,
ComponentEntityDisplayBase
::
class
,
ShortcutSetUsers
::
class
,
];
// Content migrations should have a destination plugin that is an instance
// of one of the following classes.
$content_classes
=
[
EntityContentBase
::
class
,
UrlAlias
::
class
,
BlockedIP
::
class
,
NodeCounter
::
class
,
UserData
::
class
,
];
/**
* Tests that all D7 migrations are tagged as either Configuration or Content.
*/
public
function
testD7Categories
()
{
$migrations
=
$this
->
drupal7Migrations
();
$this
->
assertArrayHasKey
(
'd7_node:page'
,
$migrations
);
$this
->
assertCategories
(
$migrations
);
}
// Instantiate all migrations.
/** @var \Drupal\migrate\Plugin\Migration[] $migrations */
$migrations
=
$this
->
migrationManager
->
createInstances
(
$definitions
);
/**
* Asserts that all migrations are tagged as either Configuration or Content.
*
* @param \Drupal\migrate\Plugin\MigrationInterface[] $migrations
* The migrations.
*/
protected
function
assertCategories
(
$migrations
)
{
foreach
(
$migrations
as
$id
=>
$migration
)
{
$object_classes
=
class_parents
(
$migration
->
getDestinationPlugin
());
$object_classes
[]
=
get_class
(
$migration
->
getDestinationPlugin
());
...
...
@@ -78,10 +76,10 @@ public function testGetGroupedDefinitions() {
// Ensure that the destination plugin is an instance of at least one of
// the expected classes.
if
(
in_array
(
'Configuration'
,
$migration
->
getMigrationTags
(),
TRUE
))
{
$this
->
assertNotEmpty
(
array_intersect
(
$object_classes
,
$
config_c
lasses
),
"The migration
$id
is tagged as Configuration."
);
$this
->
assertNotEmpty
(
array_intersect
(
$object_classes
,
$
this
->
getConfigurationC
lasses
()
),
"The migration
$id
is tagged as Configuration."
);
}
elseif
(
in_array
(
'Content'
,
$migration
->
getMigrationTags
(),
TRUE
))
{
$this
->
assertNotEmpty
(
array_intersect
(
$object_classes
,
$
c
ontent
_c
lasses
),
"The migration
$id
is tagged as Content."
);
$this
->
assertNotEmpty
(
array_intersect
(
$object_classes
,
$
this
->
getC
ontent
C
lasses
()
),
"The migration
$id
is tagged as Content."
);
}
else
{
$this
->
fail
(
"The migration
$id
is not tagged as either 'Content' or 'Configuration'."
);
...
...
@@ -89,4 +87,42 @@ public function testGetGroupedDefinitions() {
}
}
/**
* Get configuration classes.
*
* Configuration migrations should have a destination plugin that is an
* instance of one of the following classes.
*
* @return array
* The configuration class names.
*/
protected
function
getConfigurationClasses
()
{
return
[
Config
::
class
,
EntityConfigBase
::
class
,
ThemeSettings
::
class
,
ComponentEntityDisplayBase
::
class
,
ShortcutSetUsers
::
class
,
];
}
/**
* Get content classes.
*
* Content migrations should have a destination plugin that is an instance
* of one of the following classes.
*
* @return array
* The content class names.
*/
protected
function
getContentClasses
()
{
return
[
EntityContentBase
::
class
,
UrlAlias
::
class
,
BlockedIP
::
class
,
NodeCounter
::
class
,
UserData
::
class
,
];
}
}
core/modules/migrate_drupal/tests/src/Traits/CreateMigrationsTrait.php
0 → 100644
View file @
494f931e
<?php
namespace
Drupal\Tests\migrate_drupal\Traits
;
trait
CreateMigrationsTrait
{
/**
* Create instances of all Drupal 6 migrations.
*
* @return \Drupal\migrate\Plugin\MigrationInterface[]
* The migrations
*/
public
function
drupal6Migrations
()
{
$dirs
=
\
Drupal
::
service
(
'module_handler'
)
->
getModuleDirectories
();
$migrate_drupal_directory
=
$dirs
[
'migrate_drupal'
];
$this
->
loadFixture
(
"
$migrate_drupal_directory
/tests/fixtures/drupal6.php"
);
return
\
Drupal
::
service
(
'plugin.manager.migration'
)
->
createInstancesByTag
(
'Drupal 6'
);
}
/**
* Create instances of all Drupal 7 migrations.
*
* @return \Drupal\migrate\Plugin\MigrationInterface[]
* The migrations
*/
public
function
drupal7Migrations
()
{
$dirs
=
\
Drupal
::
service
(
'module_handler'
)
->
getModuleDirectories
();
$migrate_drupal_directory
=
$dirs
[
'migrate_drupal'
];
$this
->
loadFixture
(
"
$migrate_drupal_directory
/tests/fixtures/drupal7.php"
);
return
\
Drupal
::
service
(
'plugin.manager.migration'
)
->
createInstancesByTag
(
'Drupal 7'
);
}
}
core/modules/node/migrations/d6_node.yml
View file @
494f931e
...
...
@@ -3,6 +3,7 @@ label: Nodes
audit
:
true
migration_tags
:
-
Drupal
6
-
Content
deriver
:
Drupal\node\Plugin\migrate\D6NodeDeriver
source
:
plugin
:
d6_node
...
...
core/modules/node/migrations/d6_node_revision.yml
View file @
494f931e
...
...
@@ -3,6 +3,7 @@ label: Node revisions
audit
:
true
migration_tags
:
-
Drupal
6
-
Content
deriver
:
Drupal\node\Plugin\migrate\D6NodeDeriver
source
:
plugin
:
d6_node_revision
...
...
core/modules/node/migrations/d6_node_translation.yml
View file @
494f931e
...
...
@@ -2,6 +2,7 @@ id: d6_node_translation
label
:
Node translations
migration_tags
:
-
Drupal
6
-
Content
deriver
:
Drupal\node\Plugin\migrate\D6NodeDeriver
source
:
plugin
:
d6_node
...
...
core/modules/node/migrations/d7_node.yml
View file @
494f931e
...
...
@@ -3,6 +3,7 @@ label: Nodes
audit
:
true
migration_tags
:
-
Drupal
7
-
Content
deriver
:
Drupal\node\Plugin\migrate\D7NodeDeriver
source
:
plugin
:
d7_node
...
...
core/modules/node/migrations/d7_node_revision.yml
View file @
494f931e
...
...
@@ -3,6 +3,7 @@ label: Node revisions
audit
:
true
migration_tags
:
-
Drupal
7
-
Content
deriver
:
Drupal\node\Plugin\migrate\D7NodeDeriver
source
:
plugin
:
d7_node_revision
...
...
core/modules/node/migrations/d7_node_translation.yml
View file @
494f931e
...
...
@@ -3,6 +3,7 @@ label: Node translations
migration_tags
:
-
Drupal
7
-
translation
-
Content
deriver
:
Drupal\node\Plugin\migrate\D7NodeDeriver
source
:
plugin
:
d7_node
...
...
core/modules/taxonomy/migrations/d6_term_node.yml
View file @
494f931e
...
...
@@ -2,6 +2,7 @@ id: d6_term_node
label
:
Term/node relationships
migration_tags
:
-
Drupal
6
-
Content
deriver
:
Drupal\taxonomy\Plugin\migrate\D6TermNodeDeriver
source
:
plugin
:
d6_term_node
...
...
core/modules/taxonomy/migrations/d6_term_node_revision.yml
View file @
494f931e
...
...
@@ -3,6 +3,7 @@ label: Term/node relationship revisions
audit
:
true
migration_tags
:
-
Drupal
6
-
Content
deriver
:
Drupal\taxonomy\Plugin\migrate\D6TermNodeDeriver
source
:
plugin
:
d6_term_node_revision
...
...
core/modules/taxonomy/migrations/d7_taxonomy_term.yml
View file @
494f931e
...
...
@@ -3,6 +3,7 @@ label: Taxonomy terms
audit
:
true
migration_tags
:
-
Drupal
7
-
Content
deriver
:
Drupal\taxonomy\Plugin\migrate\D7TaxonomyTermDeriver
source
:
plugin
:
d7_taxonomy_term
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment