function EntityLinkSuggestionTest::providerEntityLinkSuggestions
Data provider.
Return value
\Generator Test scenarios.
File
-
core/
modules/ ckeditor5/ tests/ src/ Kernel/ EntityLinkSuggestionTest.php, line 190
Class
- EntityLinkSuggestionTest
- Tests entity link suggestions.
Namespace
Drupal\Tests\ckeditor5\KernelCode
public static function providerEntityLinkSuggestions() : \Generator {
$suggestion_node_1_en = [
'description' => 'by sofie on Tue, 19 Sep 2023 - 03:31',
'entity_type_id' => 'node',
'entity_uuid' => '36c25329-6c3b-452e-82fa-e20c502f69ed',
'group' => 'Content - Basic page',
'label' => 'foo',
'path' => '/node/1',
];
$suggestion_node_1_de = [
'description' => 'by sofie on Tue, 19 Sep 2023 - 03:31',
'entity_type_id' => 'node',
'entity_uuid' => '36c25329-6c3b-452e-82fa-e20c502f69ed',
'group' => 'Content - Basic page',
'label' => 'Deutsch foo',
'path' => '/node/1',
];
$suggestion_node_2_en = [
'description' => 'by sofie on Tue, 19 Sep 2023 - 03:32',
'entity_type_id' => 'node',
'entity_uuid' => '36c25329-6c3b-452e-82fa-e20c502f69ef',
'group' => 'Content - Article',
'label' => 'doo',
'path' => '/node/2',
];
$suggestion_node_2_de = [
'description' => 'by sofie on Tue, 19 Sep 2023 - 03:32',
'entity_type_id' => 'node',
'entity_uuid' => '36c25329-6c3b-452e-82fa-e20c502f69ef',
'group' => 'Content - Article',
'label' => 'Deutsch doo',
'path' => '/node/2',
];
$suggestion_tag_1_en = [
'description' => '',
'entity_type_id' => 'taxonomy_term',
'entity_uuid' => '966e5967-f19c-44b0-87b1-697441385b10',
'group' => 'Taxonomy term - Tags',
'label' => 'tag',
'path' => '/taxonomy/term/1',
];
$suggestion_tag_1_de = [
'description' => '',
'entity_type_id' => 'taxonomy_term',
'entity_uuid' => '966e5967-f19c-44b0-87b1-697441385b10',
'group' => 'Taxonomy term - Tags',
'label' => 'tag DE',
'path' => '/taxonomy/term/1',
];
$suggestion_tag_2_en = [
'description' => '',
'entity_type_id' => 'taxonomy_term',
'entity_uuid' => '966e5967-f19c-44b0-87b1-697441385b11',
'group' => 'Taxonomy term - Tags',
'label' => 'doo term',
'path' => '/taxonomy/term/2',
];
$suggestion_tag_2_de = [
'description' => '',
'entity_type_id' => 'taxonomy_term',
'entity_uuid' => '966e5967-f19c-44b0-87b1-697441385b11',
'group' => 'Taxonomy term - Tags',
'label' => 'doo term DE',
'path' => '/taxonomy/term/2',
];
// "f", single result due to (different) suggestion restrictions.
yield 'suggestions=nodes only, host entity type=node, host entity langcode=en, search term="f"' => [
'f',
'node',
'en',
[
$suggestion_node_1_en,
],
];
// "z", no result due to no nodes having title with "z".
yield 'host entity type=node, host entity langcode=en, search term="z"' => [
'z',
'node',
'en',
[
[
'description' => 'No content suggestions found. This URL will be used as is.',
'group' => 'No results',
'label' => 'z',
'href' => 'z',
],
],
];
// "fo", single result, but different labels due to host entity langcode.
yield 'host entity type=node, host entity langcode=en, search term="fo"' => [
'fo',
'node',
'en',
[
$suggestion_node_1_en,
],
];
yield 'host entity type=node, host entity langcode=de, search term="fo"' => [
'fo',
'node',
'de',
[
$suggestion_node_1_de,
],
];
// "tag", single result (taxonomy term), but different labels due to host entity langcode.
yield 'host entity type=node, host entity langcode=en, search term="tag"' => [
'tag',
'node',
'en',
[
$suggestion_tag_1_en,
],
];
yield 'host entity type=node, host entity langcode=de, search term="tag"' => [
'tag',
'node',
'de',
[
$suggestion_tag_1_de,
],
];
// "oo", multi results, but different labels due to host entity langcode.
yield 'host entity type=node, host entity langcode=en, search term="oo"' => [
'oo',
'node',
'en',
[
$suggestion_node_1_en,
$suggestion_node_2_en,
$suggestion_tag_2_en,
],
];
yield 'host entity type=node, host entity langcode=de, search term="oo"' => [
'oo',
'node',
'de',
[
$suggestion_node_1_de,
$suggestion_node_2_de,
$suggestion_tag_2_de,
],
];
// "Deutsch" (which appears only on a translation of an entity!), single
// result, but different labels due to host entity langcode.
yield 'host entity type=node, host entity langcode=en, search term="Deutsch"' => [
'Deutsch',
'node',
'en',
[
$suggestion_node_1_en,
$suggestion_node_2_en,
],
];
yield 'host entity type=node, host entity langcode=de, search term="Deutsch"' => [
'Deutsch',
'node',
'de',
[
$suggestion_node_1_de,
$suggestion_node_2_de,
],
];
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.