Completed
Pull Request — 8.x-1.x (#6)
by Vijay
02:33
created
src/Tests/ImageBundleTest.php 1 patch
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -11,52 +11,52 @@  discard block
 block discarded – undo
11 11
  */
12 12
 class ImageBundleTest extends WebTestBase {
13 13
 
14
-  /**
15
-   * Modules to enable.
16
-   *
17
-   * @var array
18
-   */
19
-  public static $modules = [
14
+    /**
15
+     * Modules to enable.
16
+     *
17
+     * @var array
18
+     */
19
+    public static $modules = [
20 20
     'media',
21 21
     'media_entity',
22 22
     'media_entity_image',
23 23
     'image',
24 24
     'node',
25
-  ];
25
+    ];
26 26
 
27
-  /**
28
-   * The test media bundle.
29
-   *
30
-   * @var \Drupal\media_entity\MediaBundleInterface
31
-   */
32
-  protected $testBundle;
27
+    /**
28
+     * The test media bundle.
29
+     *
30
+     * @var \Drupal\media_entity\MediaBundleInterface
31
+     */
32
+    protected $testBundle;
33 33
 
34
-  /**
35
-   * {@inheritdoc}
36
-   */
37
-  protected function setUp() {
34
+    /**
35
+     * {@inheritdoc}
36
+     */
37
+    protected function setUp() {
38 38
     parent::setUp();
39 39
     $this->testBundle = $this->container->get('entity.manager')->getStorage('media_bundle')->load('image');
40 40
 
41 41
     $adminUser = $this->drupalCreateUser([
42
-      'view media',
43
-      'create media',
44
-      'update media',
45
-      'update any media',
46
-      'delete media',
47
-      'delete any media',
48
-      'access media overview',
42
+        'view media',
43
+        'create media',
44
+        'update media',
45
+        'update any media',
46
+        'delete media',
47
+        'delete any media',
48
+        'access media overview',
49 49
     ]);
50 50
     $this->drupalLogin($adminUser);
51
-  }
51
+    }
52 52
 
53
-  /**
54
-   * Tests image media bundle creation from config files.
55
-   */
56
-  public function testMediaBundleCreationFromModule() {
53
+    /**
54
+     * Tests image media bundle creation from config files.
55
+     */
56
+    public function testMediaBundleCreationFromModule() {
57 57
     $type_configuration = [
58
-      'source_field' => 'field_image',
59
-      'gather_exif' => FALSE,
58
+        'source_field' => 'field_image',
59
+        'gather_exif' => FALSE,
60 60
     ];
61 61
 
62 62
     $this->assertTrue((bool) $this->testBundle, 'The media bundle from default configuration has been created in the database.');
@@ -65,20 +65,20 @@  discard block
 block discarded – undo
65 65
     $this->assertEqual($this->testBundle->get('type'), 'image', 'Correct plugin ID detected.');
66 66
     $this->assertEqual($this->testBundle->get('type_configuration'), $type_configuration, 'Type configuration correct.');
67 67
     $this->assertEqual($this->testBundle->get('field_map'), [], 'Correct field map detected.');
68
-  }
68
+    }
69 69
 
70
-  /**
71
-   * Tests item creation and thumbnail.
72
-   */
73
-  public function testMediaBundleItemCreation() {
70
+    /**
71
+     * Tests item creation and thumbnail.
72
+     */
73
+    public function testMediaBundleItemCreation() {
74 74
     // Define the media item name.
75 75
     $name = $this->randomMachineName();
76 76
     $image_files = $this->drupalGetTestFiles('image');
77 77
     $testImage = current($image_files);
78 78
     $file_path = $this->container->get('file_system')->realpath($testImage->uri);
79 79
     $edit = [
80
-      'name[0][value]' => $name,
81
-      'files[field_image_0]' => $file_path,
80
+        'name[0][value]' => $name,
81
+        'files[field_image_0]' => $file_path,
82 82
     ];
83 83
 
84 84
     // Save the image.
@@ -97,6 +97,6 @@  discard block
 block discarded – undo
97 97
     $thumbnail = $image->thumbnail($media);
98 98
     $default_thumbnail = $image->getDefaultThumbnail();
99 99
     $this->assertNotEqual($thumbnail, $default_thumbnail, "The thumbnail generated is different from the default thumbnail.");
100
-  }
100
+    }
101 101
 
102 102
 }
Please login to merge, or discard this patch.
media.module 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -11,13 +11,13 @@
 block discarded – undo
11 11
  * Implements hook_help().
12 12
  */
13 13
 function media_help($route_name, RouteMatchInterface $route_match) {
14
-  switch ($route_name) {
14
+    switch ($route_name) {
15 15
     // Main module help for the media module.
16 16
     case 'help.page.media':
17 17
       $output = '';
18
-      $output .= '<h3>' . t('About') . '</h3>';
19
-      $output .= '<p>' . t('Media module for Drupal 8') . '</p>';
20
-      return $output;
18
+        $output .= '<h3>' . t('About') . '</h3>';
19
+        $output .= '<p>' . t('Media module for Drupal 8') . '</p>';
20
+        return $output;
21 21
 
22 22
     default:
23 23
   }
Please login to merge, or discard this patch.
src/Tests/VideoBundleTest.php 1 patch
Indentation   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -11,56 +11,56 @@  discard block
 block discarded – undo
11 11
  */
12 12
 class VideoBundleTest extends WebTestBase {
13 13
 
14
-  /**
15
-   * Modules to enable.
16
-   *
17
-   * @var array
18
-   */
19
-  public static $modules = [
14
+    /**
15
+     * Modules to enable.
16
+     *
17
+     * @var array
18
+     */
19
+    public static $modules = [
20 20
     'media',
21 21
     'media_entity',
22 22
     'video_embed_field',
23 23
     'video_embed_media',
24 24
     'node',
25
-  ];
25
+    ];
26 26
 
27
-  /**
28
-   * The test media bundle.
29
-   *
30
-   * @var \Drupal\media_entity\MediaBundleInterface
31
-   */
32
-  protected $testBundle;
27
+    /**
28
+     * The test media bundle.
29
+     *
30
+     * @var \Drupal\media_entity\MediaBundleInterface
31
+     */
32
+    protected $testBundle;
33 33
 
34
-  /**
35
-   * {@inheritdoc}
36
-   */
37
-  protected function setUp() {
34
+    /**
35
+     * {@inheritdoc}
36
+     */
37
+    protected function setUp() {
38 38
     parent::setUp();
39 39
     $this->testBundle = $this->container->get('entity.manager')->getStorage('media_bundle')->load('video');
40 40
 
41 41
     $adminUser = $this->drupalCreateUser([
42
-      'view media',
43
-      'create media',
44
-      'update media',
45
-      'update any media',
46
-      'delete media',
47
-      'delete any media',
48
-      'access media overview',
42
+        'view media',
43
+        'create media',
44
+        'update media',
45
+        'update any media',
46
+        'delete media',
47
+        'delete any media',
48
+        'access media overview',
49 49
     ]);
50 50
     $this->drupalLogin($adminUser);
51
-  }
51
+    }
52 52
 
53
-  /**
54
-   * Tests video media bundle creation from config files.
55
-   */
56
-  public function testMediaBundleCreationFromModule() {
53
+    /**
54
+     * Tests video media bundle creation from config files.
55
+     */
56
+    public function testMediaBundleCreationFromModule() {
57 57
     $type_configuration = [
58
-      'source_field' => 'field_video',
58
+        'source_field' => 'field_video',
59 59
     ];
60 60
 
61 61
     $field_map = [
62
-      'id' => 'field_id',
63
-      'source_name' => 'field_source',
62
+        'id' => 'field_id',
63
+        'source_name' => 'field_source',
64 64
     ];
65 65
 
66 66
     $this->assertTrue((bool) $this->testBundle, 'The media bundle from default configuration has been created in the database.');
@@ -69,15 +69,15 @@  discard block
 block discarded – undo
69 69
     $this->assertEqual($this->testBundle->get('type'), 'video_embed_field', 'Correct plugin ID detected.');
70 70
     $this->assertEqual($this->testBundle->get('type_configuration'), $type_configuration, 'Type configuration correct.');
71 71
     $this->assertEqual($this->testBundle->get('field_map'), $field_map, 'Correct field map detected.');
72
-  }
72
+    }
73 73
 
74
-  /**
75
-   * Tests video media bundle field maps.
76
-   */
77
-  public function testBundleFieldMap() {
74
+    /**
75
+     * Tests video media bundle field maps.
76
+     */
77
+    public function testBundleFieldMap() {
78 78
     $edit = [
79
-      'name[0][value]' => 'Drupal video!',
80
-      'field_video[0][value]' => 'https://www.youtube.com/watch?v=XgYu7-DQjDQ',
79
+        'name[0][value]' => 'Drupal video!',
80
+        'field_video[0][value]' => 'https://www.youtube.com/watch?v=XgYu7-DQjDQ',
81 81
     ];
82 82
     $this->drupalPostForm('media/add/' . $this->testBundle->id(), $edit, t('Save and publish'));
83 83
 
@@ -86,11 +86,11 @@  discard block
 block discarded – undo
86 86
     $media_id = reset($media_id);
87 87
     /** @var \Drupal\media_entity\MediaInterface $media */
88 88
     $media = $this->container->get('entity_type.manager')
89
-      ->getStorage('media')
90
-      ->loadUnchanged($media_id);
89
+        ->getStorage('media')
90
+        ->loadUnchanged($media_id);
91 91
     $properties = $media->toArray();
92 92
     $this->assertEqual($properties['field_id'][0]['value'], 'XgYu7-DQjDQ', 'Correct video ID detected.');
93 93
     $this->assertEqual($properties['field_source'][0]['value'], 'youtube', 'Correct video source detected.');
94
-  }
94
+    }
95 95
 
96 96
 }
Please login to merge, or discard this patch.
src/Tests/GalleryBundleTest.php 1 patch
Indentation   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -11,50 +11,50 @@  discard block
 block discarded – undo
11 11
  */
12 12
 class GalleryBundleTest extends WebTestBase {
13 13
 
14
-  /**
15
-   * Modules to enable.
16
-   *
17
-   * @var array
18
-   */
19
-  public static $modules = [
14
+    /**
15
+     * Modules to enable.
16
+     *
17
+     * @var array
18
+     */
19
+    public static $modules = [
20 20
     'media',
21 21
     'media_entity',
22 22
     'media_entity_slideshow',
23 23
     'node',
24
-  ];
25
-
26
-  /**
27
-   * The test media bundle.
28
-   *
29
-   * @var \Drupal\media_entity\MediaBundleInterface
30
-   */
31
-  protected $testBundle;
32
-
33
-  /**
34
-   * {@inheritdoc}
35
-   */
36
-  protected function setUp() {
24
+    ];
25
+
26
+    /**
27
+     * The test media bundle.
28
+     *
29
+     * @var \Drupal\media_entity\MediaBundleInterface
30
+     */
31
+    protected $testBundle;
32
+
33
+    /**
34
+     * {@inheritdoc}
35
+     */
36
+    protected function setUp() {
37 37
     parent::setUp();
38 38
     $this->testBundle = $this->container->get('entity.manager')->getStorage('media_bundle')->load('gallery');
39 39
 
40 40
     $adminUser = $this->drupalCreateUser([
41
-      'view media',
42
-      'create media',
43
-      'update media',
44
-      'update any media',
45
-      'delete media',
46
-      'delete any media',
47
-      'access media overview',
41
+        'view media',
42
+        'create media',
43
+        'update media',
44
+        'update any media',
45
+        'delete media',
46
+        'delete any media',
47
+        'access media overview',
48 48
     ]);
49 49
     $this->drupalLogin($adminUser);
50
-  }
50
+    }
51 51
 
52
-  /**
53
-   * Tests gallery media bundle creation from config files.
54
-   */
55
-  public function testMediaBundleCreationFromModule() {
52
+    /**
53
+     * Tests gallery media bundle creation from config files.
54
+     */
55
+    public function testMediaBundleCreationFromModule() {
56 56
     $type_configuration = [
57
-      'source_field' => 'field_slide',
57
+        'source_field' => 'field_slide',
58 58
     ];
59 59
 
60 60
     $this->assertTrue((bool) $this->testBundle, 'The media bundle from default configuration has been created in the database.');
@@ -63,21 +63,21 @@  discard block
 block discarded – undo
63 63
     $this->assertEqual($this->testBundle->get('type'), 'slideshow', 'Correct plugin ID detected.');
64 64
     $this->assertEqual($this->testBundle->get('type_configuration'), $type_configuration, 'Type configuration correct.');
65 65
     $this->assertEqual($this->testBundle->get('field_map'), [], 'Correct field map detected.');
66
-  }
66
+    }
67 67
 
68
-  /**
69
-   * Tests thumbnail of the gallery item.
70
-   */
71
-  public function testGalleryItemThumbnail() {
68
+    /**
69
+     * Tests thumbnail of the gallery item.
70
+     */
71
+    public function testGalleryItemThumbnail() {
72 72
     // Let's add one image and one video.
73 73
     $imageItem = $this->addImageItem();
74 74
     $videoItem = $this->addVideoItem();
75 75
 
76 76
     $this->drupalGet('media/add/gallery');
77 77
     $edit = [
78
-      'name[0][value]' => 'Gallery item',
79
-      'field_slide[0][target_id]' => $imageItem['name[0][value]'] . ' (' . $imageItem['id'] . ')',
80
-      'field_slide[0][_weight]' => 0,
78
+        'name[0][value]' => 'Gallery item',
79
+        'field_slide[0][target_id]' => $imageItem['name[0][value]'] . ' (' . $imageItem['id'] . ')',
80
+        'field_slide[0][_weight]' => 0,
81 81
     ];
82 82
     $this->drupalPostAjaxForm(NULL, $edit, 'field_slide_add_more');
83 83
     $edit['field_slide[1][target_id]'] = $videoItem['name[0][value]'] . ' (' . $videoItem['id'] . ')';
@@ -97,9 +97,9 @@  discard block
 block discarded – undo
97 97
 
98 98
     $this->drupalGet('media/add/gallery');
99 99
     $edit = [
100
-      'name[0][value]' => 'Gallery item 2',
101
-      'field_slide[0][target_id]' => $videoItem['name[0][value]'] . ' (' . $videoItem['id'] . ')',
102
-      'field_slide[0][_weight]' => 0,
100
+        'name[0][value]' => 'Gallery item 2',
101
+        'field_slide[0][target_id]' => $videoItem['name[0][value]'] . ' (' . $videoItem['id'] . ')',
102
+        'field_slide[0][_weight]' => 0,
103 103
     ];
104 104
     $this->drupalPostAjaxForm(NULL, $edit, 'field_slide_add_more');
105 105
     $edit['field_slide[1][target_id]'] = $imageItem['name[0][value]'] . ' (' . $imageItem['id'] . ')';
@@ -111,19 +111,19 @@  discard block
 block discarded – undo
111 111
     $gallery = $this->loadMediaItem(reset($gallery_id));
112 112
     $gallery_thumbnail = $gallery->getType()->thumbnail($gallery);
113 113
     $this->assertEqual($gallery_thumbnail, $video_thumbnail, "Correct thumbnail detected.");
114
-  }
114
+    }
115 115
 
116
-  /**
117
-   * Adds image type item.
118
-   */
119
-  public function addImageItem() {
116
+    /**
117
+     * Adds image type item.
118
+     */
119
+    public function addImageItem() {
120 120
     // Let's add image first.
121 121
     $name = $this->randomMachineName();
122 122
     $testImage = current($this->drupalGetTestFiles('image'));
123 123
     $file_path = $this->container->get('file_system')->realpath($testImage->uri);
124 124
     $edit = [
125
-      'name[0][value]' => $name,
126
-      'files[field_image_0]' => $file_path,
125
+        'name[0][value]' => $name,
126
+        'files[field_image_0]' => $file_path,
127 127
     ];
128 128
     // Save the image.
129 129
     $this->drupalPostForm('media/add/image', $edit, t('Save and publish'));
@@ -134,15 +134,15 @@  discard block
 block discarded – undo
134 134
     $edit['id'] = $media_id;
135 135
 
136 136
     return $edit;
137
-  }
137
+    }
138 138
 
139
-  /**
140
-   * Adds video type item.
141
-   */
142
-  public function addVideoItem() {
139
+    /**
140
+     * Adds video type item.
141
+     */
142
+    public function addVideoItem() {
143 143
     $edit = [
144
-      'name[0][value]' => 'Drupal video!',
145
-      'field_video[0][value]' => 'https://www.youtube.com/watch?v=XgYu7-DQjDQ',
144
+        'name[0][value]' => 'Drupal video!',
145
+        'field_video[0][value]' => 'https://www.youtube.com/watch?v=XgYu7-DQjDQ',
146 146
     ];
147 147
     $this->drupalPostForm('media/add/video', $edit, t('Save and publish'));
148 148
     // Obtain the video id.
@@ -151,22 +151,22 @@  discard block
 block discarded – undo
151 151
     $edit['id'] = $media_id;
152 152
 
153 153
     return $edit;
154
-  }
155
-
156
-  /**
157
-   * Loads the media entity item.
158
-   *
159
-   * @param int $id
160
-   *   The id of the item.
161
-   *
162
-   * @return \Drupal\media_entity\MediaInterface
163
-   *   The media entity item.
164
-   */
165
-  public function loadMediaItem($id) {
154
+    }
155
+
156
+    /**
157
+     * Loads the media entity item.
158
+     *
159
+     * @param int $id
160
+     *   The id of the item.
161
+     *
162
+     * @return \Drupal\media_entity\MediaInterface
163
+     *   The media entity item.
164
+     */
165
+    public function loadMediaItem($id) {
166 166
     $item = $this->container->get('entity_type.manager')
167
-      ->getStorage('media')
168
-      ->loadUnchanged($id);
167
+        ->getStorage('media')
168
+        ->loadUnchanged($id);
169 169
     return $item;
170
-  }
170
+    }
171 171
 
172 172
 }
Please login to merge, or discard this patch.