3 namespace Drupal\entity_embed\Tests;
5 use Drupal\entity_browser\Entity\EntityBrowser;
6 use Drupal\embed\Entity\EmbedButton;
9 * Tests the entity_embed entity_browser integration.
13 * @dependencies entity_browser
15 class EntityEmbedEntityBrowserTest extends EntityEmbedDialogTest {
22 public static $modules = ['entity_browser'];
25 * Tests the entity browser integration.
27 public function testEntityEmbedEntityBrowserIntegration() {
28 $this->getEmbedDialog('custom_format', 'node');
29 $this->assertResponse(200, 'Embed dialog is accessible with custom filter format and default embed button.');
31 // Verify that an autocomplete field is available by default.
32 $this->assertFieldByName('entity_id', '', 'Entity ID/UUID field is present.');
33 $this->assertNoText('Select entities to embed', 'Entity browser button is not present.');
35 // Set up entity browser.
36 $entity_browser = EntityBrowser::create([
37 "name" => 'entity_embed_entity_browser_test',
38 "label" => 'Test Entity Browser for Entity Embed',
40 "display_configuration" => [
43 'link_text' => 'Select entities to embed',
45 "selection_display" => 'no_display',
46 "selection_display_configuration" => [],
47 "widget_selector" => 'single',
48 "widget_selector_configuration" => [],
51 $entity_browser->save();
53 // Enable entity browser for the default entity embed button.
54 $embed_button = EmbedButton::load('node');
55 $embed_button->type_settings['entity_browser'] = 'entity_embed_entity_browser_test';
56 $embed_button->save();
58 $this->getEmbedDialog('custom_format', 'node');
59 $this->assertResponse(200, 'Embed dialog is accessible with custom filter format and default embed button.');
61 // Verify that the autocomplete field is replaced by an entity browser
63 $this->assertNoFieldByName('entity_id', '', 'Entity ID/UUID field is present.');
64 $this->assertText('Select entities to embed', 'Entity browser button is present.');