MigrateCommentStubTest.php in Zircon Profile 8
File
core/modules/comment/src/Tests/Migrate/MigrateCommentStubTest.php
View source
<?php
namespace Drupal\comment\Tests\Migrate;
use Drupal\comment\Entity\CommentType;
use Drupal\migrate\MigrateException;
use Drupal\migrate_drupal\Tests\MigrateDrupalTestBase;
use Drupal\migrate_drupal\Tests\StubTestTrait;
use Drupal\node\Entity\NodeType;
class MigrateCommentStubTest extends MigrateDrupalTestBase {
use StubTestTrait;
public static $modules = [
'comment',
'node',
];
protected function setUp() {
parent::setUp();
$this
->installEntitySchema('comment');
$this
->installEntitySchema('node');
$storage = \Drupal::entityManager()
->getStorage('user');
$storage
->create(array(
'uid' => 0,
'status' => 0,
'name' => '',
))
->save();
NodeType::create([
'type' => 'testnodetype',
'name' => 'Test node type',
])
->save();
CommentType::create([
'id' => 'testcommenttype',
'label' => 'Test comment type',
'target_entity_type_id' => 'node',
])
->save();
}
public function testStub() {
try {
$this
->performStubTest('comment');
$this
->fail('Expected exception has not been thrown.');
} catch (MigrateException $e) {
$this
->assertIdentical($e
->getMessage(), 'Stubbing failed, unable to generate value for field entity_id');
}
$this
->createStub('node');
$this
->performStubTest('comment');
}
}