Skip to content
Snippets Groups Projects
Commit 3bacf6ec authored by Kurucz István's avatar Kurucz István
Browse files

node-type migration test

parent 1a4cc803
No related branches found
No related tags found
No related merge requests found
<?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');
}
}
<?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.');
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment