Completed
Push — 8.x-1.x ( 5c15ea...b9d72f )
by Janez
01:47
created
src/Plugin/Validation/Constraint/GalleryMediaBundleConstraint.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -14,17 +14,17 @@
 block discarded – undo
14 14
  */
15 15
 class GalleryMediaBundleConstraint extends Constraint {
16 16
 
17
-  /**
18
-   * Name of the source field for slideshow bundle.
19
-   *
20
-   * @var string
21
-   */
22
-  public $sourceFieldName;
17
+    /**
18
+     * Name of the source field for slideshow bundle.
19
+     *
20
+     * @var string
21
+     */
22
+    public $sourceFieldName;
23 23
 
24
-  /**
25
-   * The default violation message.
26
-   *
27
-   * @var string
28
-   */
29
-  public $message = 'Gallery cannot contain gallery type item.';
24
+    /**
25
+     * The default violation message.
26
+     *
27
+     * @var string
28
+     */
29
+    public $message = 'Gallery cannot contain gallery type item.';
30 30
 }
Please login to merge, or discard this patch.
tests/src/FunctionalJavascript/EmbedButtonTest.php 1 patch
Indentation   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -11,45 +11,45 @@  discard block
 block discarded – undo
11 11
  */
12 12
 class EmbedButtonTest extends JavascriptTestBase {
13 13
 
14
-  /**
15
-   * {@inheritdoc}
16
-   */
17
-  public static $modules = [
14
+    /**
15
+     * {@inheritdoc}
16
+     */
17
+    public static $modules = [
18 18
     'node',
19 19
     'path',
20 20
     'text',
21
-  ];
21
+    ];
22 22
 
23
-  /**
24
-   * {@inheritdoc}
25
-   */
26
-  public function setUp() {
23
+    /**
24
+     * {@inheritdoc}
25
+     */
26
+    public function setUp() {
27 27
     parent::setUp();
28 28
     // Manually installing modules to preserve the order.
29 29
     $this->installModule('media_embed_test');
30 30
     $this->installModule('media');
31 31
     $adminUser = $this->drupalCreateUser([
32
-      'access content',
33
-      'use text format basic_html',
34
-      'use text format full_html',
35
-      'access media_embed entity browser pages',
36
-      'view media',
37
-      'create media',
38
-      'update media',
39
-      'update any media',
40
-      'delete media',
41
-      'delete any media',
42
-      'access media overview',
43
-      'create page content',
44
-      'edit any page content',
32
+        'access content',
33
+        'use text format basic_html',
34
+        'use text format full_html',
35
+        'access media_embed entity browser pages',
36
+        'view media',
37
+        'create media',
38
+        'update media',
39
+        'update any media',
40
+        'delete media',
41
+        'delete any media',
42
+        'access media overview',
43
+        'create page content',
44
+        'edit any page content',
45 45
     ]);
46 46
     $this->drupalLogin($adminUser);
47
-  }
47
+    }
48 48
 
49
-  /**
50
-   * Tests that the entity embed dialog is working.
51
-   */
52
-  public function testMediaEmbedDialog() {
49
+    /**
50
+     * Tests that the entity embed dialog is working.
51
+     */
52
+    public function testMediaEmbedDialog() {
53 53
     // Find the button and click it to see if the modal opens.
54 54
     $this->drupalGet('node/add/page');
55 55
     $this->find('.cke_button__media')->click();
@@ -71,38 +71,38 @@  discard block
 block discarded – undo
71 71
     $this->assertEquals(200, $this->getSession()->getStatusCode());
72 72
     $filter = $this->getSession()->getPage()->find('css', 'input[name="name"]');
73 73
     $this->assertTrue($filter, "Found filter");
74
-  }
74
+    }
75 75
 
76
-  /**
77
-   * Installs the module using module_handler service.
78
-   *
79
-   * @param string $module_name
80
-   *   Name of the module to install.
81
-   */
82
-  public function installModule($module_name) {
76
+    /**
77
+     * Installs the module using module_handler service.
78
+     *
79
+     * @param string $module_name
80
+     *   Name of the module to install.
81
+     */
82
+    public function installModule($module_name) {
83 83
     if (!$this->container->get('module_handler')->moduleExists($module_name)) {
84
-      $this->container->get('module_installer')->install(array($module_name));
84
+        $this->container->get('module_installer')->install(array($module_name));
85
+    }
85 86
     }
86
-  }
87 87
 
88
-  /**
89
-   * Wait for AJAX.
90
-   */
91
-  protected function wait() {
88
+    /**
89
+     * Wait for AJAX.
90
+     */
91
+    protected function wait() {
92 92
     $this->getSession()->wait(20000, '(0 === jQuery.active)');
93
-  }
93
+    }
94 94
 
95
-  /**
96
-   * Find an element based on a CSS selector.
97
-   *
98
-   * @param string $css_selector
99
-   *   A css selector to find an element for.
100
-   *
101
-   * @return \Behat\Mink\Element\NodeElement|null
102
-   *   The found element or null.
103
-   */
104
-  protected function find($css_selector) {
95
+    /**
96
+     * Find an element based on a CSS selector.
97
+     *
98
+     * @param string $css_selector
99
+     *   A css selector to find an element for.
100
+     *
101
+     * @return \Behat\Mink\Element\NodeElement|null
102
+     *   The found element or null.
103
+     */
104
+    protected function find($css_selector) {
105 105
     return $this->getSession()->getPage()->find('css', $css_selector);
106
-  }
106
+    }
107 107
 
108 108
 }
Please login to merge, or discard this patch.
media.module 1 patch
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -13,13 +13,13 @@  discard block
 block discarded – undo
13 13
  * Implements hook_help().
14 14
  */
15 15
 function media_help($route_name, RouteMatchInterface $route_match) {
16
-  switch ($route_name) {
16
+    switch ($route_name) {
17 17
     // Main module help for the media module.
18 18
     case 'help.page.media':
19 19
       $output = '';
20
-      $output .= '<h3>' . t('About') . '</h3>';
21
-      $output .= '<p>' . t('Media module for Drupal 8') . '</p>';
22
-      return $output;
20
+        $output .= '<h3>' . t('About') . '</h3>';
21
+        $output .= '<p>' . t('Media module for Drupal 8') . '</p>';
22
+        return $output;
23 23
 
24 24
     default:
25 25
   }
@@ -29,18 +29,18 @@  discard block
 block discarded – undo
29 29
  * Implements hook_form_alter().
30 30
  */
31 31
 function media_form_alter(&$form, FormStateInterface &$form_state) {
32
-  if ($form['#form_id'] == 'entity_browser_media_library_form') {
32
+    if ($form['#form_id'] == 'entity_browser_media_library_form') {
33 33
     // Style the submit button.
34 34
     $form['actions']['submit']['#attributes']['class'][] = 'button--primary';
35 35
     $form['actions']['submit']['#attributes']['class'][] = 'entity-browser-modal-target';
36
-  }
37
-  // Remove the Gallery option from create gallery view's bundle filters.
38
-  if ($form['#id'] == 'views-exposed-form-media-library-gallery-media-select-modal' || $form['#id'] == 'views-exposed-form-media-library-gallery-user-media-select-modal') {
36
+    }
37
+    // Remove the Gallery option from create gallery view's bundle filters.
38
+    if ($form['#id'] == 'views-exposed-form-media-library-gallery-media-select-modal' || $form['#id'] == 'views-exposed-form-media-library-gallery-user-media-select-modal') {
39 39
     unset($form['bundle_1']['#options']['gallery']);
40
-  }
41
-  if ($form['#form_id'] == 'media_gallery_form') {
40
+    }
41
+    if ($form['#form_id'] == 'media_gallery_form') {
42 42
     $form['#attached']['library'][] = 'media/view';
43
-  }
43
+    }
44 44
 }
45 45
 
46 46
 /**
@@ -49,9 +49,9 @@  discard block
 block discarded – undo
49 49
  * Adds the media.view library to the media views.
50 50
  */
51 51
 function media_views_pre_render(ViewExecutable $view) {
52
-  if (isset($view) && ($view->storage->id() == 'media_library' || $view->storage->id() == 'global_media_library')) {
52
+    if (isset($view) && ($view->storage->id() == 'media_library' || $view->storage->id() == 'global_media_library')) {
53 53
     $view->element['#attached']['library'][] = 'media/view';
54
-  }
54
+    }
55 55
 }
56 56
 
57 57
 /**
@@ -60,24 +60,24 @@  discard block
 block discarded – undo
60 60
  * Adds the add media button from media_entity on library pages.
61 61
  */
62 62
 function media_menu_local_actions_alter(&$local_actions) {
63
-  $local_actions['media.add']['appears_on'][] = 'view.media_library.user_media_library';
64
-  $local_actions['media.add']['appears_on'][] = 'view.media_library.global_media_library_page';
63
+    $local_actions['media.add']['appears_on'][] = 'view.media_library.user_media_library';
64
+    $local_actions['media.add']['appears_on'][] = 'view.media_library.global_media_library_page';
65 65
 }
66 66
 
67 67
 /**
68 68
  * Implements hook_entity_type_alter().
69 69
  */
70 70
 function media_entity_type_alter(array &$entity_types) {
71
-  $field_name = \Drupal::config('media_entity.bundle.gallery')->get('type_configuration.source_field');
72
-  $entity_types['media']->addConstraint('GalleryMediaBundle', array('sourceFieldName' => $field_name));
71
+    $field_name = \Drupal::config('media_entity.bundle.gallery')->get('type_configuration.source_field');
72
+    $entity_types['media']->addConstraint('GalleryMediaBundle', array('sourceFieldName' => $field_name));
73 73
 }
74 74
 
75 75
 /**
76 76
  * Implements hook_menu_links_discovered_alter().
77 77
  */
78 78
 function media_menu_links_discovered_alter(&$links) {
79
-  // Media entity module provides a default view which we disable. Since it also
80
-  // provides a link entry for it we need to update the route there to point to
81
-  // the media library we provide.
82
-  $links['entity.media.collection']['route_name'] = 'view.media_library.global_media_library_page';
79
+    // Media entity module provides a default view which we disable. Since it also
80
+    // provides a link entry for it we need to update the route there to point to
81
+    // the media library we provide.
82
+    $links['entity.media.collection']['route_name'] = 'view.media_library.global_media_library_page';
83 83
 }
Please login to merge, or discard this patch.
src/Plugin/Validation/Constraint/GalleryMediaBundleConstraintValidator.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -10,21 +10,21 @@
 block discarded – undo
10 10
  */
11 11
 class GalleryMediaBundleConstraintValidator extends ConstraintValidator {
12 12
 
13
-  /**
14
-   * {@inheritdoc}
15
-   */
16
-  public function validate($value, Constraint $constraint) {
13
+    /**
14
+     * {@inheritdoc}
15
+     */
16
+    public function validate($value, Constraint $constraint) {
17 17
     if (!isset($value)) {
18
-      return;
18
+        return;
19 19
     }
20 20
     if ($value->hasField($constraint->sourceFieldName)) {
21
-      $slideshowItems = $value->get($constraint->sourceFieldName);
22
-      foreach ($slideshowItems as $item) {
21
+        $slideshowItems = $value->get($constraint->sourceFieldName);
22
+        foreach ($slideshowItems as $item) {
23 23
         if ($item->entity->getType()->getPluginId() == "slideshow") {
24
-          $this->context->addViolation($constraint->message);
24
+            $this->context->addViolation($constraint->message);
25 25
         }
26
-      }
26
+        }
27
+    }
27 28
     }
28
-  }
29 29
 
30 30
 }
Please login to merge, or discard this patch.
src/Tests/GalleryBundleTest.php 1 patch
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.
src/Tests/VideoBundleTest.php 1 patch
Indentation   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -10,66 +10,66 @@  discard block
 block discarded – undo
10 10
  * @group media
11 11
  */
12 12
 class VideoBundleTest 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
     'media',
29 29
     'media_entity',
30 30
     'video_embed_field',
31 31
     'video_embed_media',
32 32
     'node',
33 33
     'editor',
34
-  ];
34
+    ];
35 35
 
36
-  /**
37
-   * The test media bundle.
38
-   *
39
-   * @var \Drupal\media_entity\MediaBundleInterface
40
-   */
41
-  protected $testBundle;
36
+    /**
37
+     * The test media bundle.
38
+     *
39
+     * @var \Drupal\media_entity\MediaBundleInterface
40
+     */
41
+    protected $testBundle;
42 42
 
43
-  /**
44
-   * {@inheritdoc}
45
-   */
46
-  protected function setUp() {
43
+    /**
44
+     * {@inheritdoc}
45
+     */
46
+    protected function setUp() {
47 47
     parent::setUp();
48 48
     $this->testBundle = $this->container->get('entity.manager')->getStorage('media_bundle')->load('video');
49 49
 
50 50
     $adminUser = $this->drupalCreateUser([
51
-      'view media',
52
-      'create media',
53
-      'update media',
54
-      'update any media',
55
-      'delete media',
56
-      'delete any media',
57
-      'access media overview',
51
+        'view media',
52
+        'create media',
53
+        'update media',
54
+        'update any media',
55
+        'delete media',
56
+        'delete any media',
57
+        'access media overview',
58 58
     ]);
59 59
     $this->drupalLogin($adminUser);
60
-  }
60
+    }
61 61
 
62
-  /**
63
-   * Tests video media bundle creation from config files.
64
-   */
65
-  public function testMediaBundleCreationFromModule() {
62
+    /**
63
+     * Tests video media bundle creation from config files.
64
+     */
65
+    public function testMediaBundleCreationFromModule() {
66 66
     $type_configuration = [
67
-      'source_field' => 'field_video',
67
+        'source_field' => 'field_video',
68 68
     ];
69 69
 
70 70
     $field_map = [
71
-      'id' => 'field_id',
72
-      'source_name' => 'field_source',
71
+        'id' => 'field_id',
72
+        'source_name' => 'field_source',
73 73
     ];
74 74
 
75 75
     $this->assertTrue((bool) $this->testBundle, 'The media bundle from default configuration has been created in the database.');
@@ -78,15 +78,15 @@  discard block
 block discarded – undo
78 78
     $this->assertEqual($this->testBundle->get('type'), 'video_embed_field', 'Correct plugin ID detected.');
79 79
     $this->assertEqual($this->testBundle->get('type_configuration'), $type_configuration, 'Type configuration correct.');
80 80
     $this->assertEqual($this->testBundle->get('field_map'), $field_map, 'Correct field map detected.');
81
-  }
81
+    }
82 82
 
83
-  /**
84
-   * Tests video media bundle field maps.
85
-   */
86
-  public function testBundleFieldMap() {
83
+    /**
84
+     * Tests video media bundle field maps.
85
+     */
86
+    public function testBundleFieldMap() {
87 87
     $edit = [
88
-      'name[0][value]' => 'Drupal video!',
89
-      'field_video[0][value]' => 'https://www.youtube.com/watch?v=XgYu7-DQjDQ',
88
+        'name[0][value]' => 'Drupal video!',
89
+        'field_video[0][value]' => 'https://www.youtube.com/watch?v=XgYu7-DQjDQ',
90 90
     ];
91 91
     $this->drupalPostForm('media/add/' . $this->testBundle->id(), $edit, t('Save and publish'));
92 92
 
@@ -95,11 +95,11 @@  discard block
 block discarded – undo
95 95
     $media_id = reset($media_id);
96 96
     /** @var \Drupal\media_entity\MediaInterface $media */
97 97
     $media = $this->container->get('entity_type.manager')
98
-      ->getStorage('media')
99
-      ->loadUnchanged($media_id);
98
+        ->getStorage('media')
99
+        ->loadUnchanged($media_id);
100 100
     $properties = $media->toArray();
101 101
     $this->assertEqual($properties['field_id'][0]['value'], 'XgYu7-DQjDQ', 'Correct video ID detected.');
102 102
     $this->assertEqual($properties['field_source'][0]['value'], 'youtube', 'Correct video source detected.');
103
-  }
103
+    }
104 104
 
105 105
 }
Please login to merge, or discard this patch.
src/Tests/InstagramBundleTest.php 1 patch
Indentation   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -10,66 +10,66 @@  discard block
 block discarded – undo
10 10
  * @group media
11 11
  */
12 12
 class InstagramBundleTest 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
     'media',
29 29
     'media_entity',
30 30
     'media_entity_instagram',
31 31
     'link',
32 32
     'node',
33 33
     'editor',
34
-  ];
34
+    ];
35 35
 
36
-  /**
37
-   * The test media bundle.
38
-   *
39
-   * @var \Drupal\media_entity\MediaBundleInterface
40
-   */
41
-  protected $testBundle;
36
+    /**
37
+     * The test media bundle.
38
+     *
39
+     * @var \Drupal\media_entity\MediaBundleInterface
40
+     */
41
+    protected $testBundle;
42 42
 
43
-  /**
44
-   * {@inheritdoc}
45
-   */
46
-  protected function setUp() {
43
+    /**
44
+     * {@inheritdoc}
45
+     */
46
+    protected function setUp() {
47 47
     parent::setUp();
48 48
     $this->testBundle = $this->container->get('entity.manager')->getStorage('media_bundle')->load('instagram');
49 49
 
50 50
     $adminUser = $this->drupalCreateUser([
51
-      'view media',
52
-      'create media',
53
-      'update media',
54
-      'update any media',
55
-      'delete media',
56
-      'delete any media',
57
-      'access media overview',
51
+        'view media',
52
+        'create media',
53
+        'update media',
54
+        'update any media',
55
+        'delete media',
56
+        'delete any media',
57
+        'access media overview',
58 58
     ]);
59 59
     $this->drupalLogin($adminUser);
60
-  }
60
+    }
61 61
 
62
-  /**
63
-   * Tests instagram media bundle creation from config files.
64
-   */
65
-  public function testMediaBundleCreationFromModule() {
62
+    /**
63
+     * Tests instagram media bundle creation from config files.
64
+     */
65
+    public function testMediaBundleCreationFromModule() {
66 66
     $type_configuration = [
67
-      'use_instagram_api' => FALSE,
68
-      'source_field' => 'field_instagram_url',
69
-      'client_id'  => '',
67
+        'use_instagram_api' => FALSE,
68
+        'source_field' => 'field_instagram_url',
69
+        'client_id'  => '',
70 70
     ];
71 71
     $field_map = [
72
-      'shortcode' => 'field_instagram_shortcode',
72
+        'shortcode' => 'field_instagram_shortcode',
73 73
     ];
74 74
 
75 75
     $this->assertTrue((bool) $this->testBundle, 'The media bundle from default configuration has been created in the database.');
@@ -78,18 +78,18 @@  discard block
 block discarded – undo
78 78
     $this->assertEqual($this->testBundle->get('type'), 'instagram', 'Correct plugin ID detected.');
79 79
     $this->assertEqual($this->testBundle->get('type_configuration'), $type_configuration, 'Type configuration correct.');
80 80
     $this->assertEqual($this->testBundle->get('field_map'), $field_map, 'Correct field map detected.');
81
-  }
81
+    }
82 82
 
83
-  /**
84
-   * Tests item creation and thumbnail.
85
-   */
86
-  public function testMediaBundleItemCreation() {
83
+    /**
84
+     * Tests item creation and thumbnail.
85
+     */
86
+    public function testMediaBundleItemCreation() {
87 87
     // Define the media item name.
88 88
     $name = $this->randomMachineName();
89 89
     $instagram_url = 'https://www.instagram.com/p/C/';
90 90
     $edit = [
91
-      'name[0][value]' => $name,
92
-      'field_instagram_url[0][uri]' => $instagram_url,
91
+        'name[0][value]' => $name,
92
+        'field_instagram_url[0][uri]' => $instagram_url,
93 93
     ];
94 94
 
95 95
     // Save the Instagram post.
@@ -103,10 +103,10 @@  discard block
 block discarded – undo
103 103
     $media_id = reset($media_id);
104 104
     /** @var \Drupal\media_entity\MediaInterface $media */
105 105
     $media = $this->container->get('entity_type.manager')
106
-      ->getStorage('media')
107
-      ->loadUnchanged($media_id);
106
+        ->getStorage('media')
107
+        ->loadUnchanged($media_id);
108 108
     $properties = $media->toArray();
109 109
     $this->assertEqual($media->get('field_instagram_shortcode')[0]->getValue()['value'], "C", "Correct shortcode stored.");
110
-  }
110
+    }
111 111
 
112 112
 }
Please login to merge, or discard this patch.
src/Tests/ImageBundleTest.php 1 patch
Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -10,62 +10,62 @@  discard block
 block discarded – undo
10 10
  * @group media
11 11
  */
12 12
 class ImageBundleTest 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
     'media',
29 29
     'media_entity',
30 30
     'media_entity_image',
31 31
     'image',
32 32
     'node',
33 33
     'editor',
34
-  ];
34
+    ];
35 35
 
36
-  /**
37
-   * The test media bundle.
38
-   *
39
-   * @var \Drupal\media_entity\MediaBundleInterface
40
-   */
41
-  protected $testBundle;
36
+    /**
37
+     * The test media bundle.
38
+     *
39
+     * @var \Drupal\media_entity\MediaBundleInterface
40
+     */
41
+    protected $testBundle;
42 42
 
43
-  /**
44
-   * {@inheritdoc}
45
-   */
46
-  protected function setUp() {
43
+    /**
44
+     * {@inheritdoc}
45
+     */
46
+    protected function setUp() {
47 47
     parent::setUp();
48 48
     $this->testBundle = $this->container->get('entity.manager')->getStorage('media_bundle')->load('image');
49 49
 
50 50
     $adminUser = $this->drupalCreateUser([
51
-      'view media',
52
-      'create media',
53
-      'update media',
54
-      'update any media',
55
-      'delete media',
56
-      'delete any media',
57
-      'access media overview',
51
+        'view media',
52
+        'create media',
53
+        'update media',
54
+        'update any media',
55
+        'delete media',
56
+        'delete any media',
57
+        'access media overview',
58 58
     ]);
59 59
     $this->drupalLogin($adminUser);
60
-  }
60
+    }
61 61
 
62
-  /**
63
-   * Tests image media bundle creation from config files.
64
-   */
65
-  public function testMediaBundleCreationFromModule() {
62
+    /**
63
+     * Tests image media bundle creation from config files.
64
+     */
65
+    public function testMediaBundleCreationFromModule() {
66 66
     $type_configuration = [
67
-      'source_field' => 'field_image',
68
-      'gather_exif' => FALSE,
67
+        'source_field' => 'field_image',
68
+        'gather_exif' => FALSE,
69 69
     ];
70 70
 
71 71
     $this->assertTrue((bool) $this->testBundle, 'The media bundle from default configuration has been created in the database.');
@@ -74,20 +74,20 @@  discard block
 block discarded – undo
74 74
     $this->assertEqual($this->testBundle->get('type'), 'image', 'Correct plugin ID detected.');
75 75
     $this->assertEqual($this->testBundle->get('type_configuration'), $type_configuration, 'Type configuration correct.');
76 76
     $this->assertEqual($this->testBundle->get('field_map'), [], 'Correct field map detected.');
77
-  }
77
+    }
78 78
 
79
-  /**
80
-   * Tests item creation and thumbnail.
81
-   */
82
-  public function testMediaBundleItemCreation() {
79
+    /**
80
+     * Tests item creation and thumbnail.
81
+     */
82
+    public function testMediaBundleItemCreation() {
83 83
     // Define the media item name.
84 84
     $name = $this->randomMachineName();
85 85
     $image_files = $this->drupalGetTestFiles('image');
86 86
     $testImage = current($image_files);
87 87
     $file_path = $this->container->get('file_system')->realpath($testImage->uri);
88 88
     $edit = [
89
-      'name[0][value]' => $name,
90
-      'files[field_image_0]' => $file_path,
89
+        'name[0][value]' => $name,
90
+        'files[field_image_0]' => $file_path,
91 91
     ];
92 92
 
93 93
     // Save the image.
@@ -106,6 +106,6 @@  discard block
 block discarded – undo
106 106
     $thumbnail = $image->thumbnail($media);
107 107
     $default_thumbnail = $image->getDefaultThumbnail();
108 108
     $this->assertNotEqual($thumbnail, $default_thumbnail, "The thumbnail generated is different from the default thumbnail.");
109
-  }
109
+    }
110 110
 
111 111
 }
Please login to merge, or discard this patch.
src/Tests/TweetBundleTest.php 1 patch
Indentation   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -10,70 +10,70 @@  discard block
 block discarded – undo
10 10
  * @group media
11 11
  */
12 12
 class TweetBundleTest 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
     'media',
29 29
     'media_entity',
30 30
     'media_entity_twitter',
31 31
     'node',
32 32
     'link',
33 33
     'editor',
34
-  ];
34
+    ];
35 35
 
36
-  /**
37
-   * The test media bundle.
38
-   *
39
-   * @var \Drupal\media_entity\MediaBundleInterface
40
-   */
41
-  protected $testBundle;
36
+    /**
37
+     * The test media bundle.
38
+     *
39
+     * @var \Drupal\media_entity\MediaBundleInterface
40
+     */
41
+    protected $testBundle;
42 42
 
43
-  /**
44
-   * {@inheritdoc}
45
-   */
46
-  protected function setUp() {
43
+    /**
44
+     * {@inheritdoc}
45
+     */
46
+    protected function setUp() {
47 47
     parent::setUp();
48 48
     $this->testBundle = $this->container->get('entity.manager')->getStorage('media_bundle')->load('tweet');
49 49
 
50 50
     $adminUser = $this->drupalCreateUser([
51
-      'view media',
52
-      'create media',
53
-      'update media',
54
-      'update any media',
55
-      'delete media',
56
-      'delete any media',
57
-      'access media overview',
51
+        'view media',
52
+        'create media',
53
+        'update media',
54
+        'update any media',
55
+        'delete media',
56
+        'delete any media',
57
+        'access media overview',
58 58
     ]);
59 59
     $this->drupalLogin($adminUser);
60
-  }
60
+    }
61 61
 
62
-  /**
63
-   * Tests tweet media bundle creation from config files.
64
-   */
65
-  public function testMediaBundleCreationFromModule() {
62
+    /**
63
+     * Tests tweet media bundle creation from config files.
64
+     */
65
+    public function testMediaBundleCreationFromModule() {
66 66
     $type_configuration = [
67
-      'use_twitter_api' => FALSE,
68
-      'source_field' => 'field_tweet_url',
69
-      'consumer_key' => '',
70
-      'consumer_secret' => '',
71
-      'oauth_access_token' => '',
72
-      'oauth_access_token_secret' => '',
67
+        'use_twitter_api' => FALSE,
68
+        'source_field' => 'field_tweet_url',
69
+        'consumer_key' => '',
70
+        'consumer_secret' => '',
71
+        'oauth_access_token' => '',
72
+        'oauth_access_token_secret' => '',
73 73
     ];
74 74
     $field_map = [
75
-      'id' => 'field_tweet_id',
76
-      'user' => 'field_tweet_author',
75
+        'id' => 'field_tweet_id',
76
+        'user' => 'field_tweet_author',
77 77
     ];
78 78
 
79 79
     $this->assertTrue((bool) $this->testBundle, 'The media bundle from default configuration has been created in the database.');
@@ -82,18 +82,18 @@  discard block
 block discarded – undo
82 82
     $this->assertEqual($this->testBundle->get('type'), 'twitter', 'Correct plugin ID detected.');
83 83
     $this->assertEqual($this->testBundle->get('type_configuration'), $type_configuration, 'Type configuration correct.');
84 84
     $this->assertEqual($this->testBundle->get('field_map'), $field_map, 'Correct field map detected.');
85
-  }
85
+    }
86 86
 
87
-  /**
88
-   * Tests item creation.
89
-   */
90
-  public function testMediaBundleItemCreation() {
87
+    /**
88
+     * Tests item creation.
89
+     */
90
+    public function testMediaBundleItemCreation() {
91 91
     // Define the media item name.
92 92
     $name = $this->randomMachineName();
93 93
     $tweet_url = 'https://twitter.com/jack/status/20';
94 94
     $edit = [
95
-      'name[0][value]' => $name,
96
-      'field_tweet_url[0][uri]' => $tweet_url,
95
+        'name[0][value]' => $name,
96
+        'field_tweet_url[0][uri]' => $tweet_url,
97 97
     ];
98 98
 
99 99
     // Save the tweet.
@@ -102,11 +102,11 @@  discard block
 block discarded – undo
102 102
     $media_id = $this->container->get('entity.query')->get('media')->condition('bundle', 'tweet')->sort('created', 'DESC')->execute();
103 103
     $media_id = reset($media_id);
104 104
     $media = $this->container->get('entity_type.manager')
105
-      ->getStorage('media')
106
-      ->loadUnchanged($media_id);
105
+        ->getStorage('media')
106
+        ->loadUnchanged($media_id);
107 107
     $properties = $media->toArray();
108 108
     $this->assertEqual($media->get('field_tweet_author')[0]->getValue()['value'], "jack", "Correct tweet author stored.");
109 109
     $this->assertEqual($media->get('field_tweet_id')[0]->getValue()['value'], "20", "Correct tweet id stored.");
110
-  }
110
+    }
111 111
 
112 112
 }
Please login to merge, or discard this patch.