You are here

public function PluginTypeManagerTest::testHasPluginType in Plugin 8.2

@covers ::hasPluginType

@dataProvider providerHasPluginType

File

tests/src/Unit/PluginType/PluginTypeManagerTest.php, line 161

Class

PluginTypeManagerTest
@coversDefaultClass \Drupal\plugin\PluginType\PluginTypeManager

Namespace

Drupal\Tests\plugin\Unit\PluginType

Code

public function testHasPluginType($expected, $plugin_type_id, $module_name, $module_exists) {
  $modules = [];
  if ($module_exists) {
    $extension = $this
      ->getMockBuilder(Extension::class)
      ->disableOriginalConstructor()
      ->getMock();
    $extension
      ->expects($this
      ->atLeastOnce())
      ->method('getName')
      ->willReturn($module_name);
    $modules[] = $extension;
  }
  $this->moduleHandler
    ->expects($this
    ->any())
    ->method('getModuleList')
    ->willReturn($modules);
  $this->typedConfigurationManager
    ->expects($this
    ->any())
    ->method('hasConfigSchema')
    ->with(sprintf('plugin.plugin_configuration.%s.*', $plugin_type_id))
    ->willReturn(TRUE);
  $this
    ->assertSame($expected, $this->sut
    ->hasPluginType($plugin_type_id));
}