Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
migrate_drupal_d5
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
migrate_drupal_d5
Commits
3bacf6ec
Commit
3bacf6ec
authored
3 years ago
by
Kurucz István
Browse files
Options
Downloads
Patches
Plain Diff
node-type migration test
parent
1a4cc803
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tests/src/Kernel/MigrateDrupal5TestBase.php
+52
-0
52 additions, 0 deletions
tests/src/Kernel/MigrateDrupal5TestBase.php
tests/src/Kernel/MigrateNodeTypeTest.php
+54
-0
54 additions, 0 deletions
tests/src/Kernel/MigrateNodeTypeTest.php
with
106 additions
and
0 deletions
tests/src/Kernel/MigrateDrupal5TestBase.php
0 → 100644
+
52
−
0
View file @
3bacf6ec
<?php
namespace
Drupal\Tests\migrate_drupal_d5\Kernel
;
use
Drupal\Tests\migrate_drupal
\Kernel\MigrateDrupalTestBase
;
use
Drupal\Tests\migrate_drupal
\Traits\NodeMigrateTypeTestTrait
;
/**
* Base class for Drupal 5 migration tests.
*/
abstract
class
MigrateDrupal5TestBase
extends
MigrateDrupalTestBase
{
use
NodeMigrateTypeTestTrait
;
/**
* {@inheritdoc}
*/
protected
static
$modules
=
[
'datetime'
,
'filter'
,
'image'
,
'link'
,
'migrate_drupal_d5'
,
'node'
,
'options'
,
'telephone'
,
'text'
,
];
/**
* {@inheritdoc}
*/
protected
function
setUp
()
{
parent
::
setUp
();
$this
->
loadFixture
(
$this
->
getFixtureFilePath
());
}
/**
* Gets the path to the fixture file.
*/
protected
function
getFixtureFilePath
()
{
return
__DIR__
.
'/../../fixtures/drupal5.php'
;
}
/**
* Migrates node types.
*/
protected
function
migrateContentTypes
()
{
$this
->
installConfig
([
'node'
]);
$this
->
executeMigration
(
'd5_node_type'
);
}
}
This diff is collapsed.
Click to expand it.
tests/src/Kernel/MigrateNodeTypeTest.php
0 → 100644
+
54
−
0
View file @
3bacf6ec
<?php
namespace
Drupal\Tests\migrate_drupal_d5\Kernel
;
use
Drupal\field\Entity\FieldConfig
;
use
Drupal\node\Entity\NodeType
;
/**
* Upgrade node types to node.type.*.yml.
*
* @group migrate_drupal_5
*/
class
MigrateNodeTypeTest
extends
MigrateDrupal5TestBase
{
/**
* {@inheritdoc}
*/
protected
function
setUp
():
void
{
parent
::
setUp
();
$this
->
migrateContentTypes
();
}
/**
* Tests Drupal 5 "page" node type to Drupal 8 migration.
*/
public
function
testPageNodeType
()
{
$id_map
=
$this
->
getMigration
(
'd5_node_type'
)
->
getIdMap
();
$node_type
=
NodeType
::
load
(
'page'
);
$this
->
assertSame
(
'page'
,
$node_type
->
id
(),
'Node type page loaded'
);
$this
->
assertFalse
(
$node_type
->
displaySubmitted
());
$this
->
assertFalse
(
$node_type
->
shouldCreateNewRevision
());
$this
->
assertSame
(
DRUPAL_OPTIONAL
,
$node_type
->
getPreviewMode
());
$this
->
assertSame
(
$id_map
->
lookupDestinationIds
([
'page'
]),
[[
'page'
]]);
// Test we have a body field.
$field_body
=
FieldConfig
::
loadByName
(
'node'
,
'page'
,
'body'
);
$this
->
assertSame
(
'Body'
,
$field_body
->
getLabel
(),
'Body field was found.'
);
}
/**
* Tests Drupal 5 "book" node type to Drupal 8 migration.
*/
public
function
testBookNodeType
()
{
$id_map
=
$this
->
getMigration
(
'd5_node_type'
)
->
getIdMap
();
$node_type
=
NodeType
::
load
(
'book'
);
$this
->
assertSame
(
'book'
,
$node_type
->
id
(),
'Node type book loaded'
);
$this
->
assertTrue
(
$node_type
->
displaySubmitted
());
$this
->
assertTrue
(
$node_type
->
shouldCreateNewRevision
());
$this
->
assertSame
(
DRUPAL_OPTIONAL
,
$node_type
->
getPreviewMode
());
$this
->
assertSame
(
$id_map
->
lookupDestinationIds
([
'book'
]),
[[
'book'
]]);
// Test we have a body field.
$field_body
=
FieldConfig
::
loadByName
(
'node'
,
'book'
,
'body'
);
$this
->
assertSame
(
'Book body label'
,
$field_body
->
getLabel
(),
'Body field was found.'
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment