class ContentEntityConstructorTest

Same name in this branch
  1. main core/modules/migrate_drupal/tests/src/Kernel/Plugin/migrate/source/ContentEntityConstructorTest.php \Drupal\Tests\migrate_drupal\Kernel\Plugin\migrate\source\ContentEntityConstructorTest
Same name and namespace in other branches
  1. 10 core/modules/migrate_drupal/tests/src/Kernel/Plugin/migrate/source/ContentEntityConstructorTest.php \Drupal\Tests\migrate_drupal\Kernel\Plugin\migrate\source\ContentEntityConstructorTest
  2. 11.x core/modules/migrate_drupal/tests/src/Kernel/Plugin/migrate/source/ContentEntityConstructorTest.php \Drupal\Tests\migrate_drupal\Kernel\Plugin\migrate\source\ContentEntityConstructorTest
  3. 11.x core/modules/migrate/tests/src/Kernel/Plugin/source/ContentEntityConstructorTest.php \Drupal\Tests\migrate\Kernel\Plugin\source\ContentEntityConstructorTest
  4. 9 core/modules/migrate_drupal/tests/src/Kernel/Plugin/migrate/source/ContentEntityConstructorTest.php \Drupal\Tests\migrate_drupal\Kernel\Plugin\migrate\source\ContentEntityConstructorTest

Tests the constructor of the entity content source plugin.

Attributes

#[Group('migrate')] #[RunTestsInSeparateProcesses]

Hierarchy

Expanded class hierarchy of ContentEntityConstructorTest

File

core/modules/migrate/tests/src/Kernel/Plugin/source/ContentEntityConstructorTest.php, line 18

Namespace

Drupal\Tests\migrate\Kernel\Plugin\source
View source
class ContentEntityConstructorTest extends KernelTestBase {
  
  /**
   * {@inheritdoc}
   */
  protected static $modules = [
    'node',
    'user',
  ];
  
  /**
   * Tests the constructor.
   */
  public function testConstructor(array $configuration, array $plugin_definition, string $exception_class, string $expected) : void {
    $migration = $this->prophesize(MigrationInterface::class)
      ->reveal();
    $this->expectException($exception_class);
    $this->expectExceptionMessage($expected);
    ContentEntity::create($this->container, $configuration, 'content_entity', $plugin_definition, $migration);
  }
  
  /**
   * Provides data for constructor tests.
   */
  public static function providerTestConstructor() : array {
    return [
      'entity type missing' => [
        [],
        [
          'entity_type' => '',
        ],
        InvalidPluginDefinitionException::class,
        'Missing required "entity_type" definition.',
      ],
      'non content entity' => [
        [],
        [
          'entity_type' => 'node_type',
        ],
        InvalidPluginDefinitionException::class,
        'The entity type (node_type) is not supported. The "content_entity" source plugin only supports content entities.',
      ],
      'not bundleable' => [
        [
          'bundle' => 'foo',
        ],
        [
          'entity_type' => 'user',
        ],
        \InvalidArgumentException::class,
        'A bundle was provided but the entity type (user) is not bundleable.',
      ],
      'invalid bundle' => [
        [
          'bundle' => 'foo',
        ],
        [
          'entity_type' => 'node',
        ],
        \InvalidArgumentException::class,
        'The provided bundle (foo) is not valid for the (node) entity type.',
      ],
    ];
  }

}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.