|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Drupal\entity_embed\Tests; |
|
4
|
|
|
|
|
5
|
|
|
use Drupal\entity_browser\Entity\EntityBrowser; |
|
6
|
|
|
use Drupal\embed\Entity\EmbedButton; |
|
7
|
|
|
|
|
8
|
|
|
/** |
|
9
|
|
|
* Tests the entity_embed entity_browser integration. |
|
10
|
|
|
* |
|
11
|
|
|
* @group entity_embed |
|
12
|
|
|
* |
|
13
|
|
|
* @dependencies entity_browser |
|
14
|
|
|
*/ |
|
15
|
|
|
class EntityEmbedEntityBrowserTest extends EntityEmbedDialogTest { |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* Modules to enable. |
|
19
|
|
|
* |
|
20
|
|
|
* @var array |
|
21
|
|
|
*/ |
|
22
|
|
|
public static $modules = ['entity_browser']; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* Tests the entity browser integration. |
|
26
|
|
|
*/ |
|
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.'); |
|
30
|
|
|
|
|
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.'); |
|
34
|
|
|
|
|
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', |
|
39
|
|
|
"display" => 'modal', |
|
40
|
|
|
"display_configuration" => [ |
|
41
|
|
|
'width' => '650', |
|
42
|
|
|
'height' => '500', |
|
43
|
|
|
'link_text' => 'Select entities to embed', |
|
44
|
|
|
], |
|
45
|
|
|
"selection_display" => 'no_display', |
|
46
|
|
|
"selection_display_configuration" => [], |
|
47
|
|
|
"widget_selector" => 'single', |
|
48
|
|
|
"widget_selector_configuration" => [], |
|
49
|
|
|
"widgets" => [], |
|
50
|
|
|
]); |
|
51
|
|
|
$entity_browser->save(); |
|
52
|
|
|
|
|
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(); |
|
57
|
|
|
|
|
58
|
|
|
$this->getEmbedDialog('custom_format', 'node'); |
|
59
|
|
|
$this->assertResponse(200, 'Embed dialog is accessible with custom filter format and default embed button.'); |
|
60
|
|
|
|
|
61
|
|
|
// Verify that the autocomplete field is replaced by an entity browser |
|
62
|
|
|
// button. |
|
63
|
|
|
$this->assertNoFieldByName('entity_id', '', 'Entity ID/UUID field is present.'); |
|
64
|
|
|
$this->assertText('Select entities to embed', 'Entity browser button is present.'); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
} |
|
68
|
|
|
|