3 namespace Drupal\Tests\ckeditor\Unit;
5 use Drupal\ckeditor\CKEditorPluginManager;
6 use Drupal\editor\Entity\Editor;
7 use Drupal\Tests\UnitTestCase;
10 * @coversDefaultClass \Drupal\ckeditor\CKEditorPluginManager
14 class CKEditorPluginManagerTest extends UnitTestCase {
17 * Provides a list of configs to test.
19 public function providerGetEnabledButtons() {
30 ['name' => 'Formatting', 'items' => ['Bold', 'Italic']],
35 '1 row, >1 groups' => [
40 ['name' => 'Formatting', 'items' => ['Bold', 'Italic']],
42 ['name' => 'Linking', 'items' => ['Link']],
45 ['Bold', 'Italic', 'Link'],
47 '2 rows, 1 group each' => [
52 ['name' => 'Formatting', 'items' => ['Bold', 'Italic']],
57 ['name' => 'Tools', 'items' => ['Source']],
60 ['Bold', 'Italic', 'Source'],
62 '2 rows, >1 groups each' => [
67 ['name' => 'Formatting', 'items' => ['Bold', 'Italic']],
69 ['name' => 'Linking', 'items' => ['Link']],
74 ['name' => 'Tools', 'items' => ['Source']],
76 ['name' => 'Advanced', 'items' => ['Llama']],
79 ['Bold', 'Italic', 'Link', 'Source', 'Llama'],
85 * @covers ::getEnabledButtons
86 * @dataProvider providerGetEnabledButtons
88 public function testGetEnabledButtons(array $toolbar_rows, array $expected_buttons) {
89 $editor = $this->prophesize(Editor::class);
90 $editor->getSettings()
91 ->willReturn(['toolbar' => ['rows' => $toolbar_rows]]);
93 $enabled_buttons = CKEditorPluginManager::getEnabledButtons($editor->reveal());
94 $this->assertEquals($expected_buttons, $enabled_buttons);