MigrateBlockContentStubTest.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. namespace Drupal\Tests\block_content\Kernel\Migrate;
  3. use Drupal\block_content\Entity\BlockContentType;
  4. use Drupal\migrate\MigrateException;
  5. use Drupal\Tests\migrate_drupal\Kernel\MigrateDrupalTestBase;
  6. use Drupal\migrate_drupal\Tests\StubTestTrait;
  7. /**
  8. * Test stub creation for block_content entities.
  9. *
  10. * @group block_content
  11. */
  12. class MigrateBlockContentStubTest extends MigrateDrupalTestBase {
  13. use StubTestTrait;
  14. /**
  15. * {@inheritdoc}
  16. */
  17. public static $modules = ['block_content'];
  18. /**
  19. * {@inheritdoc}
  20. */
  21. protected function setUp() {
  22. parent::setUp();
  23. $this->installEntitySchema('block_content');
  24. }
  25. /**
  26. * Tests creation of block content stubs with no block_content_type available.
  27. */
  28. public function testStubFailure() {
  29. // Expected MigrateException thrown when no bundles exist.
  30. $this->expectException(MigrateException::class);
  31. $this->expectExceptionMessage('Stubbing failed, no bundles available for entity type: block_content');
  32. $this->createEntityStub('block_content');
  33. }
  34. /**
  35. * Tests creation of block content stubs when there is a block_content_type.
  36. */
  37. public function testStubSuccess() {
  38. BlockContentType::create([
  39. 'id' => 'test_block_content_type',
  40. 'label' => 'Test block content type',
  41. ])->save();
  42. $this->performStubTest('block_content');
  43. }
  44. }