public function MigrateFieldPluginManagerTest::testWeights in Drupal 9
Same name and namespace in other branches
- 8 core/modules/migrate_drupal/tests/src/Unit/MigrateFieldPluginManagerTest.php \Drupal\Tests\migrate_drupal\Unit\MigrateFieldPluginManagerTest::testWeights()
Tests the plugin weighting system.
@covers ::getPluginIdFromFieldType @covers ::sortDefinitions @covers ::findDefinitions @dataProvider weightsData
File
- core/modules/ migrate_drupal/ tests/ src/ Unit/ MigrateFieldPluginManagerTest.php, line 29 
Class
- MigrateFieldPluginManagerTest
- Tests the MigrateFieldPluginManager class.
Namespace
Drupal\Tests\migrate_drupal\UnitCode
public function testWeights($field_type, $core, $expected_plugin_id) {
  /** @var \Drupal\Core\Cache\CacheBackendInterface $cache */
  $cache = $this
    ->prophesize(CacheBackendInterface::class)
    ->reveal();
  /** @var \Drupal\Core\Extension\ModuleHandlerInterfaceModuleHandlerInterface $module_handler */
  $module_handler = $this
    ->prophesize(ModuleHandlerInterface::class)
    ->reveal();
  $discovery = $this
    ->prophesize(AnnotatedClassDiscovery::class);
  $discovery
    ->getDefinitions()
    ->willReturn($this
    ->pluginFixtureData());
  $manager = new MigrateFieldPluginManagerTestClass('field', new \ArrayObject(), $cache, $module_handler, MigrateField::class, $discovery
    ->reveal());
  if (!$expected_plugin_id) {
    $this
      ->expectException(PluginNotFoundException::class);
    $this
      ->expectExceptionMessage(sprintf("Plugin ID '%s' was not found.", $field_type));
  }
  $actual_plugin_id = $manager
    ->getPluginIdFromFieldType($field_type, [
    'core' => $core,
  ]);
  $this
    ->assertSame($expected_plugin_id, $actual_plugin_id);
}