EntityEmbedEntityBrowserTest.php in Entity Embed 8
File
tests/src/Functional/EntityEmbedEntityBrowserTest.php
View source
<?php
namespace Drupal\Tests\entity_embed\Functional;
use Drupal\entity_browser\Entity\EntityBrowser;
use Drupal\embed\Entity\EmbedButton;
class EntityEmbedEntityBrowserTest extends EntityEmbedDialogTest {
public static $modules = [
'entity_browser',
];
public function testEntityEmbedEntityBrowserIntegration() {
$this
->drupalGet('/entity-embed/dialog/custom_format/node');
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertSession()
->fieldExists('entity_id');
$this
->assertSession()
->linkNotExists('Select entities to embed', 'Entity browser button is not present.');
$entity_browser = EntityBrowser::create([
"name" => 'entity_embed_entity_browser_test',
"label" => 'Test Entity Browser for Entity Embed',
"display" => 'modal',
"display_configuration" => [
'width' => '650',
'height' => '500',
'link_text' => 'Select entities to embed',
],
"selection_display" => 'no_display',
"selection_display_configuration" => [],
"widget_selector" => 'single',
"widget_selector_configuration" => [],
"widgets" => [],
]);
$entity_browser
->save();
$embed_button = EmbedButton::load('node');
$embed_button->type_settings['entity_browser'] = 'entity_embed_entity_browser_test';
$embed_button
->save();
$this->container
->get('router.builder')
->rebuild();
$dependencies = $embed_button
->getDependencies();
$this
->assertContains('entity_browser.browser.entity_embed_entity_browser_test', $dependencies['config']);
$this
->drupalGet('/entity-embed/dialog/custom_format/node');
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertSession()
->fieldNotExists('entity_id');
$this
->assertSession()
->buttonExists('Select entities to embed');
}
}