summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoranon2017-03-22 23:48:37 +0100
committerEmil Stjerneman2017-03-22 23:48:37 +0100
commit78c1460a507b0d73e3875b4022c9d9c008b50e0f (patch)
tree9982cbfa3e3c3e2e1aaa4b82d91f51c6f25d836b
parent9632e2f5fd24b5570f766ec8b494c8fb1fc3ecaa (diff)
Issue #2863117 by anon: Remove IMCE integration
-rw-r--r--config/schema/linkit.schema.yml9
-rw-r--r--css/linkit.autocomplete.css4
-rw-r--r--js/autocomplete.js2
-rw-r--r--js/linkit.imce.js49
-rw-r--r--linkit.install12
-rw-r--r--linkit.libraries.yml8
-rw-r--r--linkit.module41
-rw-r--r--src/Form/Profile/FormBase.php61
-rw-r--r--src/Tests/Update/LinkitUpdateTest.php17
-rw-r--r--tests/fixtures/update/linkit-additions.php7
-rw-r--r--tests/fixtures/update/linkit.linkit_profile.test_profile_with_imce.yml24
-rw-r--r--tests/src/Functional/ImceIntegrationTest.php116
-rw-r--r--tests/src/FunctionalJavascript/LinkitDialogTest.php34
-rw-r--r--tests/src/Kernel/LinkitEditorLinkDialogTest.php33
14 files changed, 103 insertions, 314 deletions
diff --git a/config/schema/linkit.schema.yml b/config/schema/linkit.schema.yml
index e6854cf..882a2f1 100644
--- a/config/schema/linkit.schema.yml
+++ b/config/schema/linkit.schema.yml
@@ -88,15 +88,6 @@ linkit.matcher.entity:user:
include_blocked:
type: boolean
-# Third party settings on behalf of the imce module.
-linkit.linkit_profile.*.third_party.imce:
- type: mapping
- mapping:
- use:
- type: boolean
- scheme:
- type: string
-
# Plugin \Drupal\linkit\Plugin\Filter\LinkitFilter
filter_settings.linkit:
type: filter
diff --git a/css/linkit.autocomplete.css b/css/linkit.autocomplete.css
index ca374e9..ee7ed0a 100644
--- a/css/linkit.autocomplete.css
+++ b/css/linkit.autocomplete.css
@@ -71,7 +71,3 @@
.linkit-result--description img {
display: block;
}
-
-a.linkit-imce-open {
- display: inline-block;
-}
diff --git a/js/autocomplete.js b/js/autocomplete.js
index 2c1df81..44afac0 100644
--- a/js/autocomplete.js
+++ b/js/autocomplete.js
@@ -69,7 +69,7 @@
throw 'Missing path param.' + JSON.stringify(ui.item);
}
- $('input[name="attributes[href]"]', $form).val(ui.item.path);
+ $('input[name="href_dirty_check"]', $form).val(ui.item.path);
if (ui.item.entity_type_id || ui.item.entity_uuid || ui.item.substitution_id) {
if (!ui.item.entity_type_id || !ui.item.entity_uuid || !ui.item.substitution_id) {
diff --git a/js/linkit.imce.js b/js/linkit.imce.js
deleted file mode 100644
index ab6838f..0000000
--- a/js/linkit.imce.js
+++ /dev/null
@@ -1,49 +0,0 @@
-/**
- * @file
- * IMCE integration for Linkit.
- */
-
-(function ($, Drupal, drupalSettings) {
-
- 'use strict';
-
- /**
- * @namespace
- *
- * Need to be in the global namespace, otherwise the IMCE window will not show
- * the 'select' button in the toolbar.
- */
- var linkitImce = window.linkitImce = {};
-
- /**
- * Drupal behavior to handle imce linkit integration.
- */
- Drupal.behaviors.linkitImce = {
- attach: function (context, settings) {
- var $link = $(context).find('.linkit-imce-open').once('linkit-imce-open');
- if ($link.length) {
- $link.bind('click', function (event) {
- event.preventDefault();
- window.open($(this).attr('href'), '', 'width=760,height=560,resizable=1');
- });
- }
- }
- };
-
- /**
- * Handler for imce sendto operation.
- */
- linkitImce.sendto = function (file, win) {
- var imce = win.imce;
-
- if (imce.countSelection() > 1) {
- imce.setMessage(Drupal.t('You can only select one file.'));
- return;
- }
-
- var path = file.getUrl();
- $('[data-drupal-selector="edit-attributes-href"]').val(path);
- win.close();
- };
-
-})(jQuery, Drupal, drupalSettings);
diff --git a/linkit.install b/linkit.install
index 3c3fff5..bf4dc35 100644
--- a/linkit.install
+++ b/linkit.install
@@ -181,3 +181,15 @@ function linkit_update_8502() {
$profile->save(TRUE);
}
}
+
+/**
+ * Remove imce integration settings.
+ */
+function linkit_update_8503() {
+ $config_factory = \Drupal::configFactory();
+ foreach ($config_factory->listAll('linkit.linkit_profile.') as $id) {
+ $profile = $config_factory->getEditable($id);
+ $profile->clear('third_party_settings.imce');
+ $profile->save(TRUE);
+ }
+}
diff --git a/linkit.libraries.yml b/linkit.libraries.yml
index 04cc3bc..6f3bce3 100644
--- a/linkit.libraries.yml
+++ b/linkit.libraries.yml
@@ -30,11 +30,3 @@ linkit.filter_html.admin:
version: VERSION
js:
js/linkit.filter_html.admin.js: {}
-
-linkit.imce:
- version: VERSION
- js:
- js/linkit.imce.js: {}
- dependencies:
- - core/jquery.once
- - linkit/linkit.base
diff --git a/linkit.module b/linkit.module
index b42c0ec..86abac4 100644
--- a/linkit.module
+++ b/linkit.module
@@ -83,21 +83,23 @@ function linkit_form_editor_link_dialog_alter(&$form, FormStateInterface $form_s
$input = $form_state->get('link_element') ?: [];
}
- $form['linkit'] = [
- '#title' => t('URL'),
+ $form['href_dirty_check'] = [
+ '#type' => 'hidden',
+ '#default_value' => isset($input['href']) ? $input['href'] : '',
+ ];
+
+ $form['attributes']['href'] = array_merge($form['attributes']['href'], [
'#type' => 'linkit',
'#description' => t('Start typing to find content.'),
- '#maxlength' => 2048,
'#autocomplete_route_name' => 'linkit.autocomplete',
'#autocomplete_route_parameters' => [
'linkit_profile_id' => $linkit_profile_id,
],
"#weight" => -10,
'#default_value' => isset($input['href']) ? $input['href'] : '',
- ];
+ ]);
$fields = [
- 'href',
'data-entity-type',
'data-entity-uuid',
'data-entity-substitution',
@@ -113,30 +115,6 @@ function linkit_form_editor_link_dialog_alter(&$form, FormStateInterface $form_s
];
}
- // Add IMCE button if IMCE is installed and enabled for the given profile.
- if (Drupal::service('module_handler')->moduleExists('imce') && $linkit_profile->getThirdPartySetting('imce', 'use', FALSE)) {
- $form['imce-link'] = [
- '#type' => 'link',
- '#title' => t('Open IMCE file browser'),
- '#url' => Url::fromRoute('imce.page', [
- 'scheme' => $linkit_profile->getThirdPartySetting('imce', 'scheme', 'public'),
- ]),
- '#options' => [
- 'query' => [
- 'sendto' => 'linkitImce.sendto',
- ],
- ],
- '#attributes' => [
- 'class' => ['form-item', 'linkit-imce-open'],
- ],
- '#attached' => [
- 'library' => [
- 'linkit/linkit.imce',
- ],
- ],
- '#weight' => 10,
- ];
- }
// Add #submit callback that handles the data-* attributes.
array_unshift($form['#submit'], 'linkit_form_editor_link_dialog_submit');
}
@@ -148,10 +126,9 @@ function linkit_form_editor_link_dialog_submit(array &$form, FormStateInterface
$link_element = $form_state->get('link_element');
$href = $form_state->getValue(['attributes', 'href']);
- $linkit_field = $form_state->getValue(['linkit']);
+ $href_dirty_check = $form_state->getValue(['href_dirty_check']);
- if ($href !== $linkit_field) {
- $form_state->setValue(['attributes', 'href'], $linkit_field);
+ if ($href !== $href_dirty_check) {
$form_state->unsetValue(['attributes', 'data-entity-type']);
$form_state->unsetValue(['attributes', 'data-entity-uuid']);
$form_state->unsetValue(['attributes', 'data-entity-substitution']);
diff --git a/src/Form/Profile/FormBase.php b/src/Form/Profile/FormBase.php
index c2c10e3..7670a42 100644
--- a/src/Form/Profile/FormBase.php
+++ b/src/Form/Profile/FormBase.php
@@ -4,9 +4,6 @@ namespace Drupal\linkit\Form\Profile;
use Drupal\Core\Entity\EntityForm;
use Drupal\Core\Form\FormStateInterface;
-use Drupal\Core\StreamWrapper\StreamWrapperInterface;
-use Drupal\Core\StreamWrapper\StreamWrapperManager;
-use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Base form for profile add and edit forms.
@@ -21,32 +18,6 @@ abstract class FormBase extends EntityForm {
protected $entity;
/**
- * The stream wrapper manager.
- *
- * @var \Drupal\Core\StreamWrapper\StreamWrapperManager
- */
- protected $streamWrapperManager;
-
- /**
- * Constructs a FormBase object.
- *
- * @param \Drupal\Core\StreamWrapper\StreamWrapperManager $stream_wrapper_manager
- * The stream wrapper manager.
- */
- public function __construct(StreamWrapperManager $stream_wrapper_manager) {
- $this->streamWrapperManager = $stream_wrapper_manager;
- }
-
- /**
- * {@inheritdoc}
- */
- public static function create(ContainerInterface $container) {
- return new static(
- $container->get('stream_wrapper_manager')
- );
- }
-
- /**
* {@inheritdoc}
*/
public function form(array $form, FormStateInterface $form_state) {
@@ -80,33 +51,6 @@ abstract class FormBase extends EntityForm {
'#weight' => 99,
];
- if ($this->moduleHandler->moduleExists('imce')) {
- $form['imce'] = [
- '#type' => 'details',
- '#title' => $this->t('IMCE integration'),
- '#group' => 'additional_settings',
- ];
-
- $form['imce']['imce_use'] = [
- '#type' => 'checkbox',
- '#title' => $this->t('Enable IMCE File Browser in the editor dialog.'),
- '#default_value' => $this->entity->getThirdPartySetting('imce', 'use', FALSE),
- ];
-
- $scheme_options = $this->streamWrapperManager->getNames(StreamWrapperInterface::READ_VISIBLE);
- $form['imce']['imce_scheme'] = [
- '#type' => 'radios',
- '#title' => $this->t('Scheme'),
- '#options' => $scheme_options,
- '#default_value' => $this->entity->getThirdPartySetting('imce', 'scheme', 'public'),
- '#states' => [
- 'visible' => [
- ':input[name="imce_use"]' => ['checked' => TRUE],
- ],
- ],
- ];
- }
-
return parent::form($form, $form_state);
}
@@ -119,11 +63,6 @@ abstract class FormBase extends EntityForm {
// Prevent leading and trailing spaces in linkit profile labels.
$linkit_profile->set('label', trim($linkit_profile->label()));
- if ($this->moduleHandler->moduleExists('imce')) {
- $linkit_profile->setThirdPartySetting('imce', 'use', $form_state->getValue('imce_use'));
- $linkit_profile->setThirdPartySetting('imce', 'scheme', $form_state->getValue('imce_scheme'));
- }
-
$status = $linkit_profile->save();
$edit_link = $this->entity->toLink($this->t('Edit'), 'edit-form')->toString();
switch ($status) {
diff --git a/src/Tests/Update/LinkitUpdateTest.php b/src/Tests/Update/LinkitUpdateTest.php
index a17bd80..38de523 100644
--- a/src/Tests/Update/LinkitUpdateTest.php
+++ b/src/Tests/Update/LinkitUpdateTest.php
@@ -132,4 +132,21 @@ class LinkitUpdateTest extends UpdatePathTestBase {
$this->assertNotNull($test_profile->get('matchers.fc48c807-2a9c-44eb-b86b-7e134c1aa252.settings.metadata'), 'Profile have metadata');
}
+ /**
+ * Tests linkit_update_8503().
+ *
+ * @see linkit_update_8503()
+ */
+ public function testLinkitUpdate8503() {
+ $test_profile = $this->configFactory->get('linkit.linkit_profile.test_profile_imce');
+ $this->assertNotNull($test_profile->get('third_party_settings.imce.use'), 'Profile have imce use');
+ $this->assertNotNull($test_profile->get('third_party_settings.imce.scheme'), 'Profile have imce scheme');
+
+ $this->runUpdates();
+
+ $test_profile = $this->configFactory->get('linkit.linkit_profile.test_profile_imce');
+ $this->assertNull($test_profile->get('third_party_settings.imce.use'), 'Profile does not have imce use');
+ $this->assertNull($test_profile->get('third_party_settings.imce.scheme'), 'Profile does not have imce scheme');
+ }
+
}
diff --git a/tests/fixtures/update/linkit-additions.php b/tests/fixtures/update/linkit-additions.php
index 7e57ee4..22550dc 100644
--- a/tests/fixtures/update/linkit-additions.php
+++ b/tests/fixtures/update/linkit-additions.php
@@ -14,7 +14,10 @@ use Drupal\Core\Database\Database;
$connection = Database::getConnection();
// Configuration for linkit profiles.
-$config = Yaml::decode(file_get_contents(__DIR__ . '/linkit.linkit_profile.test_profile.yml'));
+$configs = [];
+$configs[] = Yaml::decode(file_get_contents(__DIR__ . '/linkit.linkit_profile.test_profile.yml'));
+$configs[] = Yaml::decode(file_get_contents(__DIR__ . '/linkit.linkit_profile.test_profile_with_imce.yml'));
+foreach ($configs as $config) {
$connection->insert('config')
->fields([
'collection',
@@ -27,7 +30,7 @@ $connection->insert('config')
'data' => serialize($config),
])
->execute();
-
+}
// Configuration for text formats.
$configs = [];
diff --git a/tests/fixtures/update/linkit.linkit_profile.test_profile_with_imce.yml b/tests/fixtures/update/linkit.linkit_profile.test_profile_with_imce.yml
new file mode 100644
index 0000000..c906d2f
--- /dev/null
+++ b/tests/fixtures/update/linkit.linkit_profile.test_profile_with_imce.yml
@@ -0,0 +1,24 @@
+uuid: 3cfc827f-07ff-456e-86db-a831e3770a03
+langcode: en
+status: true
+dependencies:
+ module:
+ - imce
+ - node
+third_party_settings:
+ imce:
+ use: 1
+ scheme: public
+id: test_profile_imce
+label: 'Test profile imce'
+description: 'This is a test profile with imce settings'
+matchers:
+ 556010a3-e317-48b3-b4ed-854c10f4b950:
+ uuid: 556010a3-e317-48b3-b4ed-854c10f4b950
+ id: 'entity:node'
+ weight: 0
+ settings:
+ result_description: 'by [node:author] | [node:created:medium]'
+ bundles: { }
+ group_by_bundle: false
+ include_unpublished: false
diff --git a/tests/src/Functional/ImceIntegrationTest.php b/tests/src/Functional/ImceIntegrationTest.php
deleted file mode 100644
index 15cdb4d..0000000
--- a/tests/src/Functional/ImceIntegrationTest.php
+++ /dev/null
@@ -1,116 +0,0 @@
-<?php
-
-namespace Drupal\Tests\linkit\Functional;
-
-use Drupal\editor\Entity\Editor;
-use Drupal\filter\Entity\FilterFormat;
-use Drupal\linkit\Tests\ProfileCreationTrait;
-
-/**
- * Tests the IMCE module integration.
- *
- * @group linkit
- */
-class ImceIntegrationTest extends LinkitBrowserTestBase {
-
- use ProfileCreationTrait;
-
- /**
- * Modules to enable.
- *
- * @var array
- */
- public static $modules = ['editor', 'ckeditor', 'imce'];
-
- /**
- * The linkit profile.
- *
- * @var \Drupal\linkit\ProfileInterface
- */
- protected $linkitProfile;
-
- /**
- * The text format to use when opening the link dialog.
- *
- * @var \Drupal\filter\FilterFormatInterface
- */
- protected $filterFormat;
-
- /**
- * The editor to bind the text format to and enable linkit on.
- *
- * @var \Drupal\editor\EditorInterface
- */
- protected $editor;
-
- /**
- * {@inheritdoc}
- */
- protected function setUp() {
- parent::setUp();
- $this->linkitProfile = $this->createProfile();
- $this->drupalLogin($this->adminUser);
-
- $this->filterFormat = FilterFormat::create([
- 'format' => 'linkit_test_format',
- 'name' => 'Linkit test format',
- 'weight' => 1,
- 'filters' => [],
- ]);
- $this->filterFormat->save();
-
- // Set up text editor.
- $this->editor = Editor::create([
- 'format' => $this->filterFormat->id(),
- 'editor' => 'ckeditor',
- ]);
- $this->editor->setSettings([
- 'plugins' => [
- 'drupallink' => [
- 'linkit_enabled' => TRUE,
- 'linkit_profile' => $this->linkitProfile->id(),
- ],
- ],
- ]);
- $this->editor->save();
-
- // Create a regular user with access to the format.
- $this->webUser = $this->drupalCreateUser([
- $this->filterFormat->getPermissionName(),
- ]);
- }
-
- /**
- * Test that the IMCE link does not shows up.
- */
- public function testImceIntegationDisabled() {
- $this->drupalLogin($this->webUser);
- $this->drupalGet('editor/dialog/link/' . $this->filterFormat->id());
- $this->assertSession()->linkNotExists('Open IMCE file browser');
- }
-
- /**
- * Test that the IMCE link shows up.
- */
- public function testImceIntegationEnabled() {
- $this->drupalGet('/admin/config/content/linkit/manage/' . $this->linkitProfile->id());
- $this->assertSession()->statusCodeEquals(200);
-
- $this->assertSession()->pageTextContains('IMCE integration');
- $this->assertSession()->fieldExists('imce_use');
-
- $edit = [];
- $edit['imce_use'] = TRUE;
- $this->drupalPostForm(NULL, $edit, t('Update profile'));
-
- $this->drupalGet('/admin/config/content/linkit/manage/' . $this->linkitProfile->id());
-
- $this->assertSession()->fieldValueEquals('edit-imce-use', '1');
-
- $this->drupalLogin($this->webUser);
-
- $this->drupalGet('editor/dialog/link/' . $this->filterFormat->id());
- $this->assertSession()->linkExists('Open IMCE file browser');
- }
-
-}
diff --git a/tests/src/FunctionalJavascript/LinkitDialogTest.php b/tests/src/FunctionalJavascript/LinkitDialogTest.php
index cb8c2ec..ac7c616 100644
--- a/tests/src/FunctionalJavascript/LinkitDialogTest.php
+++ b/tests/src/FunctionalJavascript/LinkitDialogTest.php
@@ -155,27 +155,27 @@ class LinkitDialogTest extends JavascriptTestBase {
// Wait for the form to load.
$web_assert->assertWaitOnAjaxRequest();
- // Find the linkit field.
- $linkit_field = $page->findField('linkit');
+ // Find the href field.
+ $href_field = $page->findField('attributes[href]');
- // Make sure the linkit field is an autocomplete field.
- $linkit_field->hasAttribute('data-autocomplete-path');
- $linkit_field->hasClass('form-linkit-autocomplete');
- $linkit_field->hasClass('ui-autocomplete-input');
+ // Make sure the href field is an autocomplete field.
+ $href_field->hasAttribute('data-autocomplete-path');
+ $href_field->hasClass('form-linkit-autocomplete');
+ $href_field->hasClass('ui-autocomplete-input');
// Make sure all fields are empty.
- $this->assertEmpty($linkit_field->getValue(), 'Linkit field is empty.');
+ $this->assertEmpty($href_field->getValue(), 'Href field is empty.');
$this->assertEmptyWithJs('attributes[data-entity-type]');
$this->assertEmptyWithJs('attributes[data-entity-uuid]');
$this->assertEmptyWithJs('attributes[data-entity-substitution]');
- $this->assertEmptyWithJs('attributes[href]');
+ $this->assertEmptyWithJs('href_dirty_check');
// Make sure the autocomplete result container is hidden.
$autocomplete_container = $page->find('css', 'ul.linkit-ui-autocomplete');
$this->assertFalse($autocomplete_container->isVisible());
// Trigger a keydown event to active a autocomplete search.
- $linkit_field->keyDown('f');
+ $href_field->keyDown('f');
// Wait for the results to load.
$this->getSession()->wait(5000, "jQuery('.linkit-result.ui-menu-item').length > 0");
@@ -191,13 +191,13 @@ class LinkitDialogTest extends JavascriptTestBase {
$page->find('xpath', '(//li[contains(@class, "linkit-result") and contains(@class, "ui-menu-item")])[1]')->click();
// Make sure the linkit field field is populated with the node url.
- $this->assertEquals($entity->toUrl()->toString(), $linkit_field->getValue(), 'The linkit field is populated with the node url.');
+ $this->assertEquals($entity->toUrl()->toString(), $href_field->getValue(), 'The href field is populated with the node url.');
// Make sure all other fields are populated.
$this->assertEqualsWithJs('attributes[data-entity-type]', $entity->getEntityTypeId());
$this->assertEqualsWithJs('attributes[data-entity-uuid]', $entity->uuid());
$this->assertEqualsWithJs('attributes[data-entity-substitution]', 'canonical');
- $this->assertEqualsWithJs('attributes[href]', $entity->toUrl()->toString());
+ $this->assertEqualsWithJs('href_dirty_check', $entity->toUrl()->toString());
// Save the dialog input.
$page->find('css', '.editor-link-dialog')->find('css', '.button.form-submit span')->click();
@@ -233,18 +233,18 @@ JS;
// Wait for the form to load.
$web_assert->assertWaitOnAjaxRequest();
- // Find the linkit field.
- $linkit_field = $page->findField('linkit');
- $this->assertEquals($entity->toUrl()->toString(), $linkit_field->getValue(), 'Linkit field contains the node url when edit.');
+ // Find the href field.
+ $href_field = $page->findField('attributes[href]');
+ $this->assertEquals($entity->toUrl()->toString(), $href_field->getValue(), 'Href field contains the node url when edit.');
// Make sure all other fields are populated when editing a link.
$this->assertEqualsWithJs('attributes[data-entity-type]', $entity->getEntityTypeId());
$this->assertEqualsWithJs('attributes[data-entity-uuid]', $entity->uuid());
$this->assertEqualsWithJs('attributes[data-entity-substitution]', 'canonical');
- $this->assertEqualsWithJs('attributes[href]', $entity->toUrl()->toString());
+ $this->assertEqualsWithJs('href_dirty_check', $entity->toUrl()->toString());
- // Edit the linkit field and set an external url.
- $linkit_field->setValue('http://example.com');
+ // Edit the href field and set an external url.
+ $href_field->setValue('http://example.com');
// Save the dialog input.
$page->find('css', '.editor-link-dialog')->find('css', '.button.form-submit span')->click();
diff --git a/tests/src/Kernel/LinkitEditorLinkDialogTest.php b/tests/src/Kernel/LinkitEditorLinkDialogTest.php
index dc9a79f..0a1963b 100644
--- a/tests/src/Kernel/LinkitEditorLinkDialogTest.php
+++ b/tests/src/Kernel/LinkitEditorLinkDialogTest.php
@@ -91,6 +91,7 @@ class LinkitEditorLinkDialogTest extends LinkitKernelTestBase {
*/
public function testAdd() {
$entity_label = $this->randomString();
+ /** @var \Drupal\Core\Entity\EntityInterface $entity */
$entity = EntityTest::create(['name' => $entity_label]);
$entity->save();
@@ -122,22 +123,27 @@ class LinkitEditorLinkDialogTest extends LinkitKernelTestBase {
$form_builder->prepareForm($form_id, $form, $form_state);
$form_builder->processForm($form_id, $form, $form_state);
- $this->assertEquals('linkit.autocomplete', $form['linkit']['#autocomplete_route_name'], 'Linkit is enabled on the linkit field.');
- $this->assertEmpty($form['linkit']['#default_value'], 'The linkit field is empty.');
+ $this->assertEquals('linkit.autocomplete', $form['attributes']['href']['#autocomplete_route_name'], 'Linkit is enabled on the linkit field.');
+ $this->assertEmpty($form['attributes']['href']['#default_value'], 'The linkit field is empty.');
- $form_state->setValue('linkit', 'url_without_schema');
+ $form_state->setValue(['attributes', 'href'], 'https://example.com/');
+ $form_state->setValue('href_dirty_check', '');
+ $form_state->setValue(['attributes', 'data-entity-type'], $this->randomString());
+ $form_state->setValue(['attributes', 'data-entity-uuid'], $this->randomString());
+ $form_state->setValue(['attributes', 'data-entity-substitution'], $this->randomString());
$form_builder->submitForm($form_object, $form_state);
- $this->assertEmpty($form_state->getErrors(), 'Got no validation errors for url without schema.');
$this->assertEmpty($form_state->getValue(['attributes', 'data-entity-type']));
$this->assertEmpty($form_state->getValue(['attributes', 'data-entity-uuid']));
$this->assertEmpty($form_state->getValue(['attributes', 'data-entity-substitution']));
+ $entity_url = $entity->toUrl('canonical', ['path_processing' => FALSE])->toString();
+ $form_state->setValue(['attributes', 'href'], $entity_url);
+ $form_state->setValue('href_dirty_check', $entity_url);
$form_state->setValue(['attributes', 'data-entity-type'], $entity->getEntityTypeId());
$form_state->setValue(['attributes', 'data-entity-uuid'], $entity->uuid());
$form_state->setValue(['attributes', 'data-entity-substitution'], SubstitutionManagerInterface::DEFAULT_SUBSTITUTION);
-
$form_builder->submitForm($form_object, $form_state);
- $this->assertEmpty($form_state->getErrors(), 'Got no validation errors for correct URI.');
+
$this->assertEquals($entity->getEntityTypeId(), $form_state->getValue(['attributes', 'data-entity-type']), 'Attribute "data-entity-type" exists and has the correct value.');
$this->assertEquals($entity->uuid(), $form_state->getValue(['attributes', 'data-entity-uuid']), 'Attribute "data-entity-uuid" exists and has the correct value.');
$this->assertEquals(SubstitutionManagerInterface::DEFAULT_SUBSTITUTION, $form_state->getValue(['attributes', 'data-entity-substitution']), 'Attribute "data-entity-substitution" exists and has the correct value.');
@@ -151,16 +157,13 @@ class LinkitEditorLinkDialogTest extends LinkitKernelTestBase {
/** @var \Drupal\Core\Entity\EntityInterface $entity */
$entity = EntityTest::create(['name' => $entity_label]);
$entity->save();
-
- /** @var \Drupal\Core\Entity\EntityInterface $entity_no_access */
- $entity_no_access = EntityTest::create(['name' => 'forbid_access']);
- $entity_no_access->save();
+ $entity_url = $entity->toUrl('canonical', ['path_processing' => FALSE])->toString();
$form_object = new EditorLinkDialog();
$input = [
'editor_object' => [
- 'href' => $entity->toUrl()->toString(),
+ 'href' => $entity_url,
'data-entity-type' => $entity->getEntityTypeId(),
'data-entity-uuid' => $entity->uuid(),
'data-entity-substitution' => SubstitutionManagerInterface::DEFAULT_SUBSTITUTION,
@@ -189,8 +192,8 @@ class LinkitEditorLinkDialogTest extends LinkitKernelTestBase {
$form_builder->prepareForm($form_id, $form, $form_state);
$form_builder->processForm($form_id, $form, $form_state);
- $this->assertEquals('linkit.autocomplete', $form['linkit']['#autocomplete_route_name'], 'Linkit is enabled on the linkit field.');
- $this->assertEquals($entity->toUrl()->toString(), $form['linkit']['#default_value'], 'The linkit field has the url as default value.');
+ $this->assertEquals('linkit.autocomplete', $form['attributes']['href']['#autocomplete_route_name'], 'Linkit is enabled on the href field.');
+ $this->assertEquals($entity_url, $form['attributes']['href']['#default_value'], 'The href field has the url as default value.');
$this->assertEquals($entity->getEntityTypeId(), $form_state->getValue(['attributes', 'data-entity-type']), 'Attribute "data-entity-type" exists and has the correct value.');
$this->assertEquals($entity->uuid(), $form_state->getValue(['attributes', 'data-entity-uuid']), 'Attribute "data-entity-uuid" exists and has the correct value.');
$this->assertEquals(SubstitutionManagerInterface::DEFAULT_SUBSTITUTION, $form_state->getValue(['attributes', 'data-entity-substitution']), 'Attribute "data-entity-substitution" exists and has the correct value.');
@@ -230,8 +233,8 @@ class LinkitEditorLinkDialogTest extends LinkitKernelTestBase {
$form_builder->prepareForm($form_id, $form, $form_state);
$form_builder->processForm($form_id, $form, $form_state);
- $this->assertEquals('linkit.autocomplete', $form['linkit']['#autocomplete_route_name'], 'Linkit is enabled on the href field.');
- $this->assertEquals('http://example.com/', $form['linkit']['#default_value'], 'The linkit field default value is the external URI.');
+ $this->assertEquals('linkit.autocomplete', $form['attributes']['href']['#autocomplete_route_name'], 'Linkit is enabled on the href field.');
+ $this->assertEquals('http://example.com/', $form['attributes']['href']['#default_value'], 'The href field default value is the external URI.');
$this->assertEmpty($form['attributes']['data-entity-type']['#default_value']);
$this->assertEmpty($form['attributes']['data-entity-uuid']['#default_value']);
$this->assertEmpty($form['attributes']['data-entity-substitution']['#default_value']);