MigrateBlockContentStubTest.php in Zircon Profile 8.0
File
core/modules/block_content/src/Tests/Migrate/MigrateBlockContentStubTest.php
View source
<?php
namespace Drupal\block_content\Tests\Migrate;
use Drupal\block_content\Entity\BlockContentType;
use Drupal\migrate\MigrateException;
use Drupal\migrate_drupal\Tests\MigrateDrupalTestBase;
use Drupal\migrate_drupal\Tests\StubTestTrait;
class MigrateBlockContentStubTest extends MigrateDrupalTestBase {
use StubTestTrait;
public static $modules = [
'block_content',
];
protected function setUp() {
parent::setUp();
$this
->installEntitySchema('block_content');
}
public function testStubFailure() {
$message = 'Expected MigrateException thrown when no bundles exist.';
try {
$this
->createStub('block_content');
$this
->fail($message);
} catch (MigrateException $e) {
$this
->pass($message);
$this
->assertEqual('Stubbing failed, no bundles available for entity type: block_content', $e
->getMessage());
}
}
public function testStubSuccess() {
BlockContentType::create([
'id' => 'test_block_content_type',
'label' => 'Test block content type',
])
->save();
$this
->performStubTest('block_content');
}
}