Completed
Pull Request — 8.x-1.x (#5)
by Vijay
02:37
created

testMediaBundleCreationFromModule()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 9

Duplication

Lines 12
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 9
c 1
b 0
f 0
nc 1
nop 0
dl 12
loc 12
rs 9.4285
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 View Code Duplication
    public function testMediaBundleCreationFromModule() {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
40
        $type_configuration = [
41
            'source_field' => 'field_media_video_embed_field'
42
        ];
43
44
        $this->assertTrue((bool) $this->testBundle, 'The media bundle from default configuration has been created in the database.');
45
        $this->assertEqual($this->testBundle->get('label'), 'Video', 'Correct label detected.');
46
        $this->assertEqual($this->testBundle->get('description'), 'Use Video for embedding videos hosted by YouTube, Vimeo, or some other provider.', 'Correct description detected.');
47
        $this->assertEqual($this->testBundle->get('type'), 'video_embed_field', 'Correct plugin ID detected.');
48
        $this->assertEqual($this->testBundle->get('type_configuration'), $type_configuration, 'Type configuration correct.');
49
        $this->assertEqual($this->testBundle->get('field_map'), [], 'Correct field map detected.');
50
    }
51
}
52