|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Drupal\media\Tests; |
|
4
|
|
|
|
|
5
|
|
|
use Drupal\simpletest\WebTestBase; |
|
6
|
|
|
|
|
7
|
|
|
/** |
|
8
|
|
|
* Ensures that media bundle for videos can be created. |
|
9
|
|
|
* |
|
10
|
|
|
* @group media |
|
11
|
|
|
*/ |
|
12
|
|
|
class VideoBundleTest extends WebTestBase { |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* Modules to enable. |
|
16
|
|
|
* |
|
17
|
|
|
* @var array |
|
18
|
|
|
*/ |
|
19
|
|
|
public static $modules = ['media', 'media_entity', 'video_embed_field', 'video_embed_media']; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* The test media bundle. |
|
23
|
|
|
* |
|
24
|
|
|
* @var \Drupal\media_entity\MediaBundleInterface |
|
25
|
|
|
*/ |
|
26
|
|
|
protected $testBundle; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* {@inheritdoc} |
|
30
|
|
|
*/ |
|
31
|
|
|
protected function setUp() { |
|
32
|
|
|
parent::setUp(); |
|
33
|
|
|
$this->testBundle = $this->container->get('entity.manager')->getStorage('media_bundle')->load('video'); |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* Tests video media bundle creation from config files. |
|
38
|
|
|
*/ |
|
39
|
|
|
public function testMediaBundleCreationFromModule() { |
|
40
|
|
|
$type_configuration = [ |
|
41
|
|
|
'source_field' => 'field_video' |
|
42
|
|
|
]; |
|
43
|
|
|
|
|
44
|
|
|
$field_map = [ |
|
45
|
|
|
'id' => 'field_id', |
|
46
|
|
|
'source_name' => 'field_source' |
|
47
|
|
|
]; |
|
48
|
|
|
|
|
49
|
|
|
$this->assertTrue((bool) $this->testBundle, 'The media bundle from default configuration has been created in the database.'); |
|
50
|
|
|
$this->assertEqual($this->testBundle->get('label'), 'Video', 'Correct label detected.'); |
|
51
|
|
|
$this->assertEqual($this->testBundle->get('description'), 'Use Video for embedding videos hosted by YouTube, Vimeo, or some other provider.', 'Correct description detected.'); |
|
52
|
|
|
$this->assertEqual($this->testBundle->get('type'), 'video_embed_field', 'Correct plugin ID detected.'); |
|
53
|
|
|
$this->assertEqual($this->testBundle->get('type_configuration'), $type_configuration, 'Type configuration correct.'); |
|
54
|
|
|
$this->assertEqual($this->testBundle->get('field_map'), $field_map, 'Correct field map detected.'); |
|
55
|
|
|
} |
|
56
|
|
|
} |
|
57
|
|
|
|