function SmartDefaultSettingsTest::testCandidates

Tests candidates.

@legacy-covers ::getCandidates @legacy-covers ::selectCandidate

Attributes

#[DataProvider('providerCandidates')]

File

core/modules/ckeditor5/tests/src/Unit/SmartDefaultSettingsTest.php, line 96

Class

SmartDefaultSettingsTest
Tests Drupal\ckeditor5\SmartDefaultSettings.

Namespace

Drupal\Tests\ckeditor5\Unit

Code

public function testCandidates(HTMLRestrictions $provided, HTMLRestrictions $still_needed, array $disabled_plugin_definitions, array $expected_candidates, array $expected_selection = []) : void {
  $get_candidates = self::getMethod(SmartDefaultSettings::class, 'getCandidates');
  $smart_default_settings = new SmartDefaultSettings($this->prophesize(CKEditor5PluginManagerInterface::class)
    ->reveal(), $this->prophesize(LoggerInterface::class)
    ->reveal(), $this->prophesize(ModuleHandlerInterface::class)
    ->reveal(), $this->prophesize(AccountInterface::class)
    ->reveal());
  $editor = $this->prophesize(EditorInterface::class);
  $this->assertSame($expected_candidates, $get_candidates->invoke($smart_default_settings, $provided, $still_needed, $disabled_plugin_definitions, $editor->reveal()));
  $select_candidate = self::getMethod(SmartDefaultSettings::class, 'selectCandidate');
  $this->assertSame($expected_selection, $select_candidate->invoke(NULL, $expected_candidates, $still_needed, array_keys($provided->getAllowedElements())));
}

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