Completed
Pull Request — 8.x-1.x (#15)
by Vijay
02:59
created
src/Tests/GalleryBundleTest.php 2 patches
Indentation   +87 added lines, -87 removed lines patch added patch discarded remove patch
@@ -10,61 +10,61 @@  discard block
 block discarded – undo
10 10
  * @group media
11 11
  */
12 12
 class GalleryBundleTest 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 = [
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 28
     'media',
29 29
     'media_entity',
30 30
     'media_entity_slideshow',
31 31
     'node',
32 32
     'editor',
33
-  ];
34
-
35
-  /**
36
-   * The test media bundle.
37
-   *
38
-   * @var \Drupal\media_entity\MediaBundleInterface
39
-   */
40
-  protected $testBundle;
41
-
42
-  /**
43
-   * {@inheritdoc}
44
-   */
45
-  protected function setUp() {
33
+    ];
34
+
35
+    /**
36
+     * The test media bundle.
37
+     *
38
+     * @var \Drupal\media_entity\MediaBundleInterface
39
+     */
40
+    protected $testBundle;
41
+
42
+    /**
43
+     * {@inheritdoc}
44
+     */
45
+    protected function setUp() {
46 46
     parent::setUp();
47 47
     $this->testBundle = $this->container->get('entity_type.manager')->getStorage('media_bundle')->load('gallery');
48 48
 
49 49
     $adminUser = $this->drupalCreateUser([
50
-      'view media',
51
-      'create media',
52
-      'update media',
53
-      'update any media',
54
-      'delete media',
55
-      'delete any media',
56
-      'access media overview',
57
-      'access gallery_media_library entity browser pages',
50
+        'view media',
51
+        'create media',
52
+        'update media',
53
+        'update any media',
54
+        'delete media',
55
+        'delete any media',
56
+        'access media overview',
57
+        'access gallery_media_library entity browser pages',
58 58
     ]);
59 59
     $this->drupalLogin($adminUser);
60
-  }
60
+    }
61 61
 
62
-  /**
63
-   * Tests gallery media bundle creation from config files.
64
-   */
65
-  public function testMediaBundleCreationFromModule() {
62
+    /**
63
+     * Tests gallery media bundle creation from config files.
64
+     */
65
+    public function testMediaBundleCreationFromModule() {
66 66
     $type_configuration = [
67
-      'source_field' => 'field_slide',
67
+        'source_field' => 'field_slide',
68 68
     ];
69 69
 
70 70
     $this->assertTrue((bool) $this->testBundle, 'The media bundle from default configuration has been created in the database.');
@@ -73,21 +73,21 @@  discard block
 block discarded – undo
73 73
     $this->assertEqual($this->testBundle->get('type'), 'slideshow', 'Correct plugin ID detected.');
74 74
     $this->assertEqual($this->testBundle->get('type_configuration'), $type_configuration, 'Type configuration correct.');
75 75
     $this->assertEqual($this->testBundle->get('field_map'), [], 'Correct field map detected.');
76
-  }
76
+    }
77 77
 
78
-  /**
79
-   * Tests thumbnail of the gallery item.
80
-   */
81
-  public function testGalleryItemThumbnail() {
78
+    /**
79
+     * Tests thumbnail of the gallery item.
80
+     */
81
+    public function testGalleryItemThumbnail() {
82 82
     // Let's add one image and one video.
83 83
     $imageItem = $this->addImageItem();
84 84
     $videoItem = $this->addVideoItem();
85 85
     $this->drupalGet('media/add/gallery');
86 86
     $pathValue = (string) current($this->xpath('//input[@data-drupal-selector="edit-field-slide-entity-browser-entity-browser-path"]/@value'));
87 87
     $edit = [
88
-      'name[0][value]' => 'Gallery item',
89
-      'field_slide[target_id]' => 'media:' . $imageItem['id'] . ' media:' . $videoItem['id'],
90
-      'field_slide[entity_browser][entity_browser][path]' => $pathValue,
88
+        'name[0][value]' => 'Gallery item',
89
+        'field_slide[target_id]' => 'media:' . $imageItem['id'] . ' media:' . $videoItem['id'],
90
+        'field_slide[entity_browser][entity_browser][path]' => $pathValue,
91 91
     ];
92 92
     $this->drupalPostForm(NULL, $edit, t('Save and publish'));
93 93
 
@@ -104,9 +104,9 @@  discard block
 block discarded – undo
104 104
 
105 105
     $this->drupalGet('media/add/gallery');
106 106
     $edit = [
107
-      'name[0][value]' => 'Gallery item 2',
108
-      'field_slide[target_id]' => 'media:' . $videoItem['id'] . ' media:' . $imageItem['id'] ,
109
-      'field_slide[entity_browser][entity_browser][path]' => $pathValue,
107
+        'name[0][value]' => 'Gallery item 2',
108
+        'field_slide[target_id]' => 'media:' . $videoItem['id'] . ' media:' . $imageItem['id'] ,
109
+        'field_slide[entity_browser][entity_browser][path]' => $pathValue,
110 110
     ];
111 111
     $this->drupalPostForm(NULL, $edit, t('Save and publish'));
112 112
 
@@ -115,28 +115,28 @@  discard block
 block discarded – undo
115 115
     $gallery = $this->loadMediaItem(reset($gallery_id));
116 116
     $gallery_thumbnail = $gallery->getType()->thumbnail($gallery);
117 117
     $this->assertEqual($gallery_thumbnail, $video_thumbnail, "Correct thumbnail detected.");
118
-  }
118
+    }
119 119
 
120
-  /**
121
-   * Tests that gallery option isn't available in gallery create bundle filters.
122
-   */
123
-  public function testGalleryOption() {
120
+    /**
121
+     * Tests that gallery option isn't available in gallery create bundle filters.
122
+     */
123
+    public function testGalleryOption() {
124 124
     // Open the media library iframe used on add gallery page.
125 125
     $this->drupalGet('entity-browser/modal/gallery_media_library');
126 126
     $this->assertNoOption('edit-bundle-1', 'gallery');
127
-  }
127
+    }
128 128
 
129
-  /**
130
-   * Adds image type item.
131
-   */
132
-  public function addImageItem() {
129
+    /**
130
+     * Adds image type item.
131
+     */
132
+    public function addImageItem() {
133 133
     // Let's add image first.
134 134
     $name = $this->randomMachineName();
135 135
     $testImage = current($this->drupalGetTestFiles('image'));
136 136
     $file_path = $this->container->get('file_system')->realpath($testImage->uri);
137 137
     $edit = [
138
-      'name[0][value]' => $name,
139
-      'files[field_image_0]' => $file_path,
138
+        'name[0][value]' => $name,
139
+        'files[field_image_0]' => $file_path,
140 140
     ];
141 141
     // Save the image.
142 142
     $this->drupalPostForm('media/add/image', $edit, t('Save and publish'));
@@ -147,15 +147,15 @@  discard block
 block discarded – undo
147 147
     $edit['id'] = $media_id;
148 148
 
149 149
     return $edit;
150
-  }
150
+    }
151 151
 
152
-  /**
153
-   * Adds video type item.
154
-   */
155
-  public function addVideoItem() {
152
+    /**
153
+     * Adds video type item.
154
+     */
155
+    public function addVideoItem() {
156 156
     $edit = [
157
-      'name[0][value]' => 'Drupal video!',
158
-      'field_video[0][value]' => 'https://www.youtube.com/watch?v=XgYu7-DQjDQ',
157
+        'name[0][value]' => 'Drupal video!',
158
+        'field_video[0][value]' => 'https://www.youtube.com/watch?v=XgYu7-DQjDQ',
159 159
     ];
160 160
     $this->drupalPostForm('media/add/video', $edit, t('Save and publish'));
161 161
     // Obtain the video id.
@@ -164,22 +164,22 @@  discard block
 block discarded – undo
164 164
     $edit['id'] = $media_id;
165 165
 
166 166
     return $edit;
167
-  }
168
-
169
-  /**
170
-   * Loads the media entity item.
171
-   *
172
-   * @param int $id
173
-   *   The id of the item.
174
-   *
175
-   * @return \Drupal\media_entity\MediaInterface
176
-   *   The media entity item.
177
-   */
178
-  public function loadMediaItem($id) {
167
+    }
168
+
169
+    /**
170
+     * Loads the media entity item.
171
+     *
172
+     * @param int $id
173
+     *   The id of the item.
174
+     *
175
+     * @return \Drupal\media_entity\MediaInterface
176
+     *   The media entity item.
177
+     */
178
+    public function loadMediaItem($id) {
179 179
     $item = $this->container->get('entity_type.manager')
180
-      ->getStorage('media')
181
-      ->loadUnchanged($id);
180
+        ->getStorage('media')
181
+        ->loadUnchanged($id);
182 182
     return $item;
183
-  }
183
+    }
184 184
 
185 185
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -105,7 +105,7 @@
 block discarded – undo
105 105
     $this->drupalGet('media/add/gallery');
106 106
     $edit = [
107 107
       'name[0][value]' => 'Gallery item 2',
108
-      'field_slide[target_id]' => 'media:' . $videoItem['id'] . ' media:' . $imageItem['id'] ,
108
+      'field_slide[target_id]' => 'media:' . $videoItem['id'] . ' media:' . $imageItem['id'],
109 109
       'field_slide[entity_browser][entity_browser][path]' => $pathValue,
110 110
     ];
111 111
     $this->drupalPostForm(NULL, $edit, t('Save and publish'));
Please login to merge, or discard this patch.
src/Tests/EntityEmbedTest.php 1 patch
Indentation   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -10,56 +10,56 @@  discard block
 block discarded – undo
10 10
  * @group media
11 11
  */
12 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;
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 21
 
22
-  /**
23
-   * Modules to enable.
24
-   *
25
-   * @var array
26
-   */
27
-  public static $modules = [
22
+    /**
23
+     * Modules to enable.
24
+     *
25
+     * @var array
26
+     */
27
+    public static $modules = [
28 28
     'node',
29 29
     'path',
30 30
     'text',
31
-  ];
31
+    ];
32 32
 
33
-  /**
34
-   * {@inheritdoc}
35
-   */
36
-  protected function setUp() {
33
+    /**
34
+     * {@inheritdoc}
35
+     */
36
+    protected function setUp() {
37 37
     parent::setUp();
38 38
     // Manually installing modules to preserve the order.
39 39
     $this->installModule('media_embed_test');
40 40
     $this->installModule('media');
41 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',
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 55
     ]);
56 56
     $this->drupalLogin($adminUser);
57
-  }
57
+    }
58 58
 
59
-  /**
60
-   * Tests that the entity embed dialog is working.
61
-   */
62
-  public function testEntityEmbedDialog() {
59
+    /**
60
+     * Tests that the entity embed dialog is working.
61
+     */
62
+    public function testEntityEmbedDialog() {
63 63
     // Test for the button in the basic_html editor.
64 64
     $this->drupalGet('entity-embed/dialog/basic_html/media');
65 65
     $this->assertResponse(200, 'Embed dialog is accessible after installation of media module.');
@@ -73,15 +73,15 @@  discard block
 block discarded – undo
73 73
     $this->drupalGet('entity-browser/iframe/media_embed');
74 74
     $this->assertResponse(200, 'All media is accessible inside the EB.');
75 75
     $this->assertFieldByName('name', NULL, 'Media name filter is accessible.');
76
-  }
76
+    }
77 77
 
78
-  /**
79
-   * Installs the module using module_handler service.
80
-   */
81
-  public function installModule($module_name) {
78
+    /**
79
+     * Installs the module using module_handler service.
80
+     */
81
+    public function installModule($module_name) {
82 82
     if (!$this->container->get('module_handler')->moduleExists($module_name)) {
83
-      $this->container->get('module_installer')->install(array($module_name));
83
+        $this->container->get('module_installer')->install(array($module_name));
84
+    }
84 85
     }
85
-  }
86 86
 
87 87
 }
Please login to merge, or discard this patch.