Version 1
[yaffs-website] / web / core / modules / block_content / tests / src / Kernel / Migrate / MigrateBlockContentStubTest.php
1 <?php
2
3 namespace Drupal\Tests\block_content\Kernel\Migrate;
4
5 use Drupal\block_content\Entity\BlockContentType;
6 use Drupal\migrate\MigrateException;
7 use Drupal\Tests\migrate_drupal\Kernel\MigrateDrupalTestBase;
8 use Drupal\migrate_drupal\Tests\StubTestTrait;
9
10 /**
11  * Test stub creation for block_content entities.
12  *
13  * @group block_content
14  */
15 class MigrateBlockContentStubTest extends MigrateDrupalTestBase {
16
17   use StubTestTrait;
18
19   /**
20    * {@inheritdoc}
21    */
22   public static $modules = ['block_content'];
23
24   /**
25    * {@inheritdoc}
26    */
27   protected function setUp() {
28     parent::setUp();
29     $this->installEntitySchema('block_content');
30   }
31
32   /**
33    * Tests creation of block content stubs with no block_content_type available.
34    */
35   public function testStubFailure() {
36     $message = 'Expected MigrateException thrown when no bundles exist.';
37     try {
38       $this->createStub('block_content');
39       $this->fail($message);
40     }
41     catch (MigrateException $e) {
42       $this->pass($message);
43       $this->assertEqual('Stubbing failed, no bundles available for entity type: block_content', $e->getMessage());
44     }
45   }
46
47   /**
48    * Tests creation of block content stubs when there is a block_content_type.
49    */
50   public function testStubSuccess() {
51     BlockContentType::create([
52       'id' => 'test_block_content_type',
53       'label' => 'Test block content type',
54     ])->save();
55     $this->performStubTest('block_content');
56   }
57
58 }