View source
<?php
namespace Drupal\node\Tests\Migrate\d7;
use Drupal\field\Entity\FieldConfig;
use Drupal\field\FieldConfigInterface;
use Drupal\migrate_drupal\Tests\d7\MigrateDrupal7TestBase;
use Drupal\node\Entity\NodeType;
use Drupal\node\NodeTypeInterface;
class MigrateNodeTypeTest extends MigrateDrupal7TestBase {
public static $modules = array(
'node',
'text',
'filter',
);
protected function setUp() {
parent::setUp();
$this
->installConfig(array(
'node',
));
$this
->executeMigration('d7_node_type');
}
protected function assertEntity($id, $label, $description, $help, $display_submitted, $new_revision, $body_label = NULL) {
$entity = NodeType::load($id);
$this
->assertTrue($entity instanceof NodeTypeInterface);
$this
->assertIdentical($label, $entity
->label());
$this
->assertIdentical($description, $entity
->getDescription());
$this
->assertIdentical($help, $entity
->getHelp());
$this
->assertIdentical($display_submitted, $entity
->displaySubmitted(), 'Submission info is displayed');
$this
->assertIdentical($new_revision, $entity
->isNewRevision(), 'Is a new revision');
if ($body_label) {
$body = FieldConfig::load('node.' . $id . '.body');
$this
->assertTrue($body instanceof FieldConfigInterface);
$this
->assertIdentical($body_label, $body
->label());
}
}
public function testNodeType() {
$this
->assertEntity('article', 'Article', 'Use <em>articles</em> for time-sensitive content like news, press releases or blog posts.', 'Help text for articles', TRUE, FALSE, "Body");
$this
->assertEntity('blog', 'Blog entry', 'Use for multi-user blogs. Every user gets a personal blog.', 'Blog away, good sir!', TRUE, FALSE, 'Body');
$this
->assertEntity('book', 'Book page', '<em>Books</em> have a built-in hierarchical navigation. Use for handbooks or tutorials.', '', TRUE, TRUE, "Body");
$this
->assertEntity('forum', 'Forum topic', 'A <em>forum topic</em> starts a new discussion thread within a forum.', 'No name-calling, no flame wars. Be nice.', TRUE, FALSE, 'Body');
$this
->assertEntity('page', 'Basic page', "Use <em>basic pages</em> for your static content, such as an 'About us' page.", 'Help text for basic pages', FALSE, FALSE, "Body");
$this
->assertEntity('test_content_type', 'Test content type', 'This is the description of the test content type.', 'Help text for test content type', FALSE, TRUE);
}
}