You are here

public function MigrationProvidersExistTest::testFieldProviderMissingRequiredProperty in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/migrate/tests/src/Kernel/Plugin/MigrationProvidersExistTest.php \Drupal\Tests\migrate\Kernel\Plugin\MigrationProvidersExistTest::testFieldProviderMissingRequiredProperty()
  2. 10 core/modules/migrate/tests/src/Kernel/Plugin/MigrationProvidersExistTest.php \Drupal\Tests\migrate\Kernel\Plugin\MigrationProvidersExistTest::testFieldProviderMissingRequiredProperty()

Test a missing required definition.

@dataProvider fieldPluginDefinitionsProvider

Parameters

array $definitions: A field plugin definition.

string $missing_property: The name of the property missing from the definition.

File

core/modules/migrate/tests/src/Kernel/Plugin/MigrationProvidersExistTest.php, line 164

Class

MigrationProvidersExistTest
Tests that modules exist for all source and destination plugins.

Namespace

Drupal\Tests\migrate\Kernel\Plugin

Code

public function testFieldProviderMissingRequiredProperty(array $definitions, $missing_property) {
  $discovery = $this
    ->getMockBuilder(MigrateFieldPluginManager::class)
    ->disableOriginalConstructor()
    ->setMethods([
    'getDefinitions',
  ])
    ->getMock();
  $discovery
    ->method('getDefinitions')
    ->willReturn($definitions);
  $plugin_manager = $this
    ->getMockBuilder(MigrateFieldPluginManager::class)
    ->disableOriginalConstructor()
    ->setMethods([
    'getDiscovery',
  ])
    ->getMock();
  $plugin_manager
    ->method('getDiscovery')
    ->willReturn($discovery);
  $this
    ->expectException(BadPluginDefinitionException::class);
  $this
    ->expectExceptionMessage("The missing_{$missing_property} plugin must define the {$missing_property} property.");
  $plugin_manager
    ->getDefinitions();
}