Completed
Pull Request — 8.x-1.x (#8)
by Vijay
02:13
created
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.
media.module 2 patches
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -12,13 +12,13 @@  discard block
 block discarded – undo
12 12
  * Implements hook_help().
13 13
  */
14 14
 function media_help($route_name, RouteMatchInterface $route_match) {
15
-  switch ($route_name) {
15
+    switch ($route_name) {
16 16
     // Main module help for the media module.
17 17
     case 'help.page.media':
18 18
       $output = '';
19
-      $output .= '<h3>' . t('About') . '</h3>';
20
-      $output .= '<p>' . t('Media module for Drupal 8') . '</p>';
21
-      return $output;
19
+        $output .= '<h3>' . t('About') . '</h3>';
20
+        $output .= '<p>' . t('Media module for Drupal 8') . '</p>';
21
+        return $output;
22 22
 
23 23
     default:
24 24
   }
@@ -28,28 +28,28 @@  discard block
 block discarded – undo
28 28
  * Implements hook_form_alter().
29 29
  */
30 30
 function media_form_alter(&$form, FormStateInterface &$form_state) {
31
-  if (isset($form['#form_id'])) {
31
+    if (isset($form['#form_id'])) {
32 32
     if ($form['#form_id'] == 'entity_browser_media_library_form') {
33
-      // Attach our library.
34
-      $form['#attached']['library'][] = 'media/view';
33
+        // Attach our library.
34
+        $form['#attached']['library'][] = 'media/view';
35 35
 
36
-      // Style the submit button.
37
-      $form['actions']['submit']['#value'] = t('Select Media Files');
38
-      $form['actions']['submit']['#attributes']['class'][] = 'button--primary';
39
-      $form['actions']['submit']['#attributes']['class'][] = 'entity-browser-modal-target';
36
+        // Style the submit button.
37
+        $form['actions']['submit']['#value'] = t('Select Media Files');
38
+        $form['actions']['submit']['#attributes']['class'][] = 'button--primary';
39
+        $form['actions']['submit']['#attributes']['class'][] = 'entity-browser-modal-target';
40 40
 
41
-      // Wrap actions so we can float them at the bottom of the browser.
42
-      $form['actions_wrap'] = [
41
+        // Wrap actions so we can float them at the bottom of the browser.
42
+        $form['actions_wrap'] = [
43 43
         '#type' => 'container',
44 44
         '#attributes' => [
45
-          'class' => 'file-browser-actions',
45
+            'class' => 'file-browser-actions',
46 46
         ],
47 47
         0 => $form['actions'],
48
-      ];
49
-      unset($form['actions']);
48
+        ];
49
+        unset($form['actions']);
50 50
 
51
-      // Add a class for generic styling.
52
-      $form['#attributes']['class'][] = 'file-browser-form';
51
+        // Add a class for generic styling.
52
+        $form['#attributes']['class'][] = 'file-browser-form';
53
+    }
53 54
     }
54
-  }
55 55
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@
 block discarded – undo
27 27
 /**
28 28
  * Implements hook_form_alter().
29 29
  */
30
-function media_form_alter(&$form, FormStateInterface &$form_state) {
30
+function media_form_alter(&$form, FormStateInterface & $form_state) {
31 31
   if (isset($form['#form_id'])) {
32 32
     if ($form['#form_id'] == 'entity_browser_media_library_form') {
33 33
       // Attach our library.
Please login to merge, or discard this patch.