You are here

protected function LinkitEditorLinkDialogTest::setUp in Linkit 8.5

Sets up the test.

Overrides LinkitKernelTestBase::setUp

File

tests/src/Kernel/LinkitEditorLinkDialogTest.php, line 46

Class

LinkitEditorLinkDialogTest
Tests EditorLinkDialog validation and conversion functionality.

Namespace

Drupal\Tests\linkit\Kernel

Code

protected function setUp() {
  parent::setUp();
  $this
    ->installEntitySchema('entity_test');
  $this
    ->installSchema('system', [
    'key_value_expire',
  ]);

  // Create a profile.
  $this->linkitProfile = $this
    ->createProfile();

  /** @var \Drupal\linkit\MatcherManager $matcherManager */
  $matcherManager = $this->container
    ->get('plugin.manager.linkit.matcher');

  // Add the entity_test matcher to the profile.

  /** @var \Drupal\linkit\MatcherInterface $plugin */
  $plugin = $matcherManager
    ->createInstance('entity:entity_test');
  $this->linkitProfile
    ->addMatcher($plugin
    ->getConfiguration());
  $this->linkitProfile
    ->save();

  // Add a text format.
  $format = FilterFormat::create([
    'format' => 'filtered_html',
    'name' => 'Filtered HTML',
    'weight' => 0,
    'filters' => [],
  ]);
  $format
    ->save();

  // Set up editor.
  $this->editor = Editor::create([
    'format' => 'filtered_html',
    'editor' => 'ckeditor',
  ]);
  $this->editor
    ->setSettings([
    'plugins' => [
      'drupallink' => [
        'linkit_enabled' => TRUE,
        'linkit_profile' => $this->linkitProfile
          ->id(),
      ],
    ],
  ]);
  $this->editor
    ->save();
}