You are here

public function AdvancedPluginSelectorBaseTest::testBuildSelectorFormWithoutAvailablePlugins in Plugin 8.2

@covers ::buildSelectorForm @covers ::setPluginSelector

File

tests/src/Unit/Plugin/Plugin/PluginSelector/AdvancedPluginSelectorBaseTest.php, line 130

Class

AdvancedPluginSelectorBaseTest
@coversDefaultClass \Drupal\plugin\Plugin\Plugin\PluginSelector\AdvancedPluginSelectorBase

Namespace

Drupal\Tests\plugin\Unit\Plugin\Plugin\PluginSelector

Code

public function testBuildSelectorFormWithoutAvailablePlugins() {
  $form = [];
  $form_state = $this
    ->createMock(FormStateInterface::class);
  $this->selectablePluginManager
    ->expects($this
    ->any())
    ->method('getDefinitions')
    ->willReturn([]);
  $build = $this->sut
    ->buildSelectorForm($form, $form_state);
  unset($build['container']['#plugin_selector_form_state_key']);
  $expected_build = [
    '#cache' => [
      'contexts' => [],
      'tags' => [],
      'max-age' => Cache::PERMANENT,
    ],
    'container' => [
      '#attributes' => [
        'class' => [
          'plugin-selector-' . Html::getId($this->pluginId),
        ],
      ],
      '#available_plugins' => [],
      '#process' => [
        [
          AdvancedPluginSelectorBase::class,
          'processBuildSelectorForm',
        ],
      ],
      '#tree' => TRUE,
      '#type' => 'container',
    ],
  ];
  $this
    ->assertSame($expected_build, $build);
}