1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @file |
5
|
|
|
* Contains \Drupal\entity_embed\Tests\EntityEmbedEntityBrowserTest. |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
namespace Drupal\entity_embed\Tests; |
9
|
|
|
|
10
|
|
|
use Drupal\entity_browser\Entity\EntityBrowser; |
11
|
|
|
use Drupal\embed\Entity\EmbedButton; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Tests the entity_embed entity_browser integration. |
15
|
|
|
* |
16
|
|
|
* @group entity_embed |
17
|
|
|
* @dependencies entity_browser |
18
|
|
|
*/ |
19
|
|
|
class EntityEmbedEntityBrowserTest extends EntityEmbedDialogTest { |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* Modules to enable. |
23
|
|
|
* |
24
|
|
|
* @var array |
25
|
|
|
*/ |
26
|
|
|
public static $modules = ['entity_browser']; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* Tests the entity browser integration. |
30
|
|
|
*/ |
31
|
|
|
public function testEntityEmbedEntityBrowserIntegration() { |
32
|
|
|
$this->getEmbedDialog('custom_format', 'node'); |
33
|
|
|
$this->assertResponse(200, 'Embed dialog is accessible with custom filter format and default embed button.'); |
34
|
|
|
|
35
|
|
|
// Verify that an autocomplete field is available by default. |
36
|
|
|
$this->assertFieldByName('attributes[data-entity-id]', '', 'Entity ID/UUID field is present.'); |
37
|
|
|
$this->assertNoText('Select entities to embed', 'Entity browser button is not present.'); |
38
|
|
|
|
39
|
|
|
// Set up entity browser. |
40
|
|
|
$entity_browser = EntityBrowser::create([ |
41
|
|
|
"name" => 'entity_embed_entity_browser_test', |
42
|
|
|
"label" => 'Test Entity Browser for Entity Embed', |
43
|
|
|
"display" => 'modal', |
44
|
|
|
"display_configuration" => [ |
45
|
|
|
'width' => '650', |
46
|
|
|
'height' => '500', |
47
|
|
|
'link_text' => 'Select entities to embed', |
48
|
|
|
], |
49
|
|
|
"selection_display" => 'no_display', |
50
|
|
|
"selection_display_configuration" => [], |
51
|
|
|
"widget_selector" => 'single', |
52
|
|
|
"widget_selector_configuration" => [], |
53
|
|
|
"widgets" => [], |
54
|
|
|
]); |
55
|
|
|
$entity_browser->save(); |
56
|
|
|
|
57
|
|
|
// Enable entity browser for the default entity embed button. |
58
|
|
|
$embed_button = EmbedButton::load('node'); |
59
|
|
|
$embed_button->type_settings['entity_browser'] = 'entity_embed_entity_browser_test'; |
60
|
|
|
$embed_button->save(); |
61
|
|
|
|
62
|
|
|
$this->getEmbedDialog('custom_format', 'node'); |
63
|
|
|
$this->assertResponse(200, 'Embed dialog is accessible with custom filter format and default embed button.'); |
64
|
|
|
|
65
|
|
|
// Verify that the autocomplete field is replaced by an entity browser |
66
|
|
|
// button. |
67
|
|
|
$this->assertNoFieldByName('attributes[data-entity-id]', '', 'Entity ID/UUID field is present.'); |
68
|
|
|
$this->assertText('Select entities to embed', 'Entity browser button is present.'); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
} |
72
|
|
|
|