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