|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Drupal\media\Tests; |
|
4
|
|
|
|
|
5
|
|
|
use Drupal\simpletest\WebTestBase; |
|
6
|
|
|
|
|
7
|
|
|
/** |
|
8
|
|
|
* Ensures that embedding functionality works perfectly. |
|
9
|
|
|
* |
|
10
|
|
|
* @group media |
|
11
|
|
|
*/ |
|
12
|
|
|
class EntityEmbedTest extends WebTestBase { |
|
13
|
|
|
/** |
|
14
|
|
|
* Exempt from strict schema checking. |
|
15
|
|
|
* |
|
16
|
|
|
* @see \Drupal\Core\Config\Testing\ConfigSchemaChecker |
|
17
|
|
|
* |
|
18
|
|
|
* @var bool |
|
19
|
|
|
*/ |
|
20
|
|
|
protected $strictConfigSchema = FALSE; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* Modules to enable. |
|
24
|
|
|
* |
|
25
|
|
|
* @var array |
|
26
|
|
|
*/ |
|
27
|
|
|
public static $modules = [ |
|
28
|
|
|
'node', |
|
29
|
|
|
'path', |
|
30
|
|
|
'text', |
|
31
|
|
|
]; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* {@inheritdoc} |
|
35
|
|
|
*/ |
|
36
|
|
|
protected function setUp() { |
|
37
|
|
|
parent::setUp(); |
|
38
|
|
|
// Manually installing modules to preserve the order. |
|
39
|
|
|
$this->installModule('media_embed_test'); |
|
40
|
|
|
$this->installModule('media'); |
|
41
|
|
|
$adminUser = $this->drupalCreateUser([ |
|
42
|
|
|
'access content', |
|
43
|
|
|
'use text format basic_html', |
|
44
|
|
|
'use text format full_html', |
|
45
|
|
|
'access media_embed entity browser pages', |
|
46
|
|
|
'view media', |
|
47
|
|
|
'create media', |
|
48
|
|
|
'update media', |
|
49
|
|
|
'update any media', |
|
50
|
|
|
'delete media', |
|
51
|
|
|
'delete any media', |
|
52
|
|
|
'access media overview', |
|
53
|
|
|
'create page content', |
|
54
|
|
|
'edit any page content', |
|
55
|
|
|
]); |
|
56
|
|
|
$this->drupalLogin($adminUser); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* Tests that the entity embed dialog is working. |
|
61
|
|
|
*/ |
|
62
|
|
|
public function testEntityEmbedDialog() { |
|
63
|
|
|
// Test for the button in the basic_html editor. |
|
64
|
|
|
$this->drupalGet('entity-embed/dialog/basic_html/media'); |
|
65
|
|
|
$this->assertResponse(200, 'Embed dialog is accessible after installation of media module.'); |
|
66
|
|
|
$this->assertText('Select media to embed', 'Entity browser title is present.'); |
|
67
|
|
|
|
|
68
|
|
|
// Test for the button in the full_html editor. |
|
69
|
|
|
$this->drupalGet('entity-embed/dialog/full_html/media'); |
|
70
|
|
|
$this->assertResponse(200, 'Embed dialog is accessible after installation of media module.'); |
|
71
|
|
|
$this->assertText('Select media to embed', 'Entity browser title is present.'); |
|
72
|
|
|
|
|
73
|
|
|
$this->drupalGet('entity-browser/iframe/media_embed'); |
|
74
|
|
|
$this->assertResponse(200, 'All media is accessible inside the EB.'); |
|
75
|
|
|
$this->assertFieldByName('name', NULL, 'Media name filter is accessible.'); |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
/** |
|
79
|
|
|
* Installs the module using module_handler service. |
|
80
|
|
|
*/ |
|
81
|
|
|
public function installModule($module_name) { |
|
82
|
|
|
if (!$this->container->get('module_handler')->moduleExists($module_name)) { |
|
83
|
|
|
$this->container->get('module_installer')->install(array($module_name)); |
|
84
|
|
|
} |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
} |
|
88
|
|
|
|