MigrateTermNodeTest.php in Zircon Profile 8
File
core/modules/taxonomy/src/Tests/Migrate/d6/MigrateTermNodeTest.php
View source
<?php
namespace Drupal\taxonomy\Tests\Migrate\d6;
use Drupal\migrate\Entity\Migration;
use Drupal\migrate\Plugin\MigrateIdMapInterface;
use Drupal\migrate\Row;
use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
use Drupal\node\Entity\Node;
class MigrateTermNodeTest extends MigrateDrupal6TestBase {
public static $modules = [
'taxonomy',
];
protected function setUp() {
parent::setUp();
$this
->installSchema('node', [
'node_access',
]);
$this
->migrateContent();
$this
->migrateTaxonomy();
}
public function testTermNode() {
$this
->executeMigrations([
'd6_term_node:*',
]);
$this->container
->get('entity.manager')
->getStorage('node')
->resetCache([
1,
2,
]);
$nodes = Node::loadMultiple([
1,
2,
]);
$node = $nodes[1];
$this
->assertIdentical(1, count($node->vocabulary_1_i_0_));
$this
->assertIdentical('1', $node->vocabulary_1_i_0_[0]->target_id);
$node = $nodes[2];
$this
->assertIdentical(2, count($node->vocabulary_2_i_1_));
$this
->assertIdentical('2', $node->vocabulary_2_i_1_[0]->target_id);
$this
->assertIdentical('3', $node->vocabulary_2_i_1_[1]->target_id);
}
public function testSkipNonExistentNode() {
$this
->mockFailure('d6_node__story', [
'nid' => 2,
]);
$migration = Migration::load('d6_term_node__2');
$this
->executeMigration($migration);
$this
->assertNull($migration
->getIdMap()
->lookupDestinationId([
'vid' => 3,
])[0]);
}
}