Commit b81d3614 authored by anon's avatar anon

by anon: Minor test fixes.

parent f1fc37a4
......@@ -123,13 +123,14 @@ class LinkitEditorLinkDialogTest extends LinkitKernelTestBase {
$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('', $form['linkit']['#default_value'], 'The linkit field is empty.');
$this->assertEmpty($form['linkit']['#default_value'], 'The linkit field is empty.');
$form_state->setValue('linkit', 'url_without_schema');
$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']));
$form_state->setValue(['attributes', 'data-entity-type'], $entity->getEntityTypeId());
$form_state->setValue(['attributes', 'data-entity-uuid'], $entity->uuid());
......
<?php
namespace Drupal\Tests\linkit\Kernel\Matchers;
use Drupal\linkit\MatcherInterface;
use Drupal\linkit\Suggestion\SuggestionCollection;
/**
* Provides helper methods for assertions.
*/
trait AssertResultUriTrait {
/**
* Assert that paths are formatted as an URI with the entity: scheme.
*
* @param \Drupal\linkit\MatcherInterface $plugin
* A matcher plugin.
* @param \Drupal\linkit\Suggestion\SuggestionCollection $suggestions
* A collection of suggestions.
*/
public function assertResultUri(MatcherInterface $plugin, SuggestionCollection $suggestions) {
$entity_type = $plugin->getPluginDefinition()['target_entity'];
$substitution_id = $plugin->getConfiguration()['settings']['substitution_type'];
foreach ($suggestions->getSuggestions() as $suggestion) {
$this->assertTrue(preg_match("/^entity:" . $substitution_id . "\\/" . $entity_type . "\\/\\w+$/i", $suggestion->getPath()), 'Result URI correct formatted.');
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment