@@ -10,65 +10,65 @@ discard block |
||
| 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 | + ]; |
|
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * The test media bundle. |
|
| 37 | - * |
|
| 38 | - * @var \Drupal\media_entity\MediaBundleInterface |
|
| 39 | - */ |
|
| 40 | - protected $testBundle; |
|
| 35 | + /** |
|
| 36 | + * The test media bundle. |
|
| 37 | + * |
|
| 38 | + * @var \Drupal\media_entity\MediaBundleInterface |
|
| 39 | + */ |
|
| 40 | + protected $testBundle; |
|
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * {@inheritdoc} |
|
| 44 | - */ |
|
| 45 | - protected function setUp() { |
|
| 42 | + /** |
|
| 43 | + * {@inheritdoc} |
|
| 44 | + */ |
|
| 45 | + protected function setUp() { |
|
| 46 | 46 | parent::setUp(); |
| 47 | 47 | $this->testBundle = $this->container->get('entity.manager')->getStorage('media_bundle')->load('video'); |
| 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', |
|
| 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 | 57 | ]); |
| 58 | 58 | $this->drupalLogin($adminUser); |
| 59 | - } |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - /** |
|
| 62 | - * Tests video media bundle creation from config files. |
|
| 63 | - */ |
|
| 64 | - public function testMediaBundleCreationFromModule() { |
|
| 61 | + /** |
|
| 62 | + * Tests video media bundle creation from config files. |
|
| 63 | + */ |
|
| 64 | + public function testMediaBundleCreationFromModule() { |
|
| 65 | 65 | $type_configuration = [ |
| 66 | - 'source_field' => 'field_video', |
|
| 66 | + 'source_field' => 'field_video', |
|
| 67 | 67 | ]; |
| 68 | 68 | |
| 69 | 69 | $field_map = [ |
| 70 | - 'id' => 'field_id', |
|
| 71 | - 'source_name' => 'field_source', |
|
| 70 | + 'id' => 'field_id', |
|
| 71 | + 'source_name' => 'field_source', |
|
| 72 | 72 | ]; |
| 73 | 73 | |
| 74 | 74 | $this->assertTrue((bool) $this->testBundle, 'The media bundle from default configuration has been created in the database.'); |
@@ -77,15 +77,15 @@ discard block |
||
| 77 | 77 | $this->assertEqual($this->testBundle->get('type'), 'video_embed_field', 'Correct plugin ID detected.'); |
| 78 | 78 | $this->assertEqual($this->testBundle->get('type_configuration'), $type_configuration, 'Type configuration correct.'); |
| 79 | 79 | $this->assertEqual($this->testBundle->get('field_map'), $field_map, 'Correct field map detected.'); |
| 80 | - } |
|
| 80 | + } |
|
| 81 | 81 | |
| 82 | - /** |
|
| 83 | - * Tests video media bundle field maps. |
|
| 84 | - */ |
|
| 85 | - public function testBundleFieldMap() { |
|
| 82 | + /** |
|
| 83 | + * Tests video media bundle field maps. |
|
| 84 | + */ |
|
| 85 | + public function testBundleFieldMap() { |
|
| 86 | 86 | $edit = [ |
| 87 | - 'name[0][value]' => 'Drupal video!', |
|
| 88 | - 'field_video[0][value]' => 'https://www.youtube.com/watch?v=XgYu7-DQjDQ', |
|
| 87 | + 'name[0][value]' => 'Drupal video!', |
|
| 88 | + 'field_video[0][value]' => 'https://www.youtube.com/watch?v=XgYu7-DQjDQ', |
|
| 89 | 89 | ]; |
| 90 | 90 | $this->drupalPostForm('media/add/' . $this->testBundle->id(), $edit, t('Save and publish')); |
| 91 | 91 | |
@@ -94,11 +94,11 @@ discard block |
||
| 94 | 94 | $media_id = reset($media_id); |
| 95 | 95 | /** @var \Drupal\media_entity\MediaInterface $media */ |
| 96 | 96 | $media = $this->container->get('entity_type.manager') |
| 97 | - ->getStorage('media') |
|
| 98 | - ->loadUnchanged($media_id); |
|
| 97 | + ->getStorage('media') |
|
| 98 | + ->loadUnchanged($media_id); |
|
| 99 | 99 | $properties = $media->toArray(); |
| 100 | 100 | $this->assertEqual($properties['field_id'][0]['value'], 'XgYu7-DQjDQ', 'Correct video ID detected.'); |
| 101 | 101 | $this->assertEqual($properties['field_source'][0]['value'], 'youtube', 'Correct video source detected.'); |
| 102 | - } |
|
| 102 | + } |
|
| 103 | 103 | |
| 104 | 104 | } |
@@ -10,61 +10,61 @@ discard block |
||
| 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 | + ]; |
|
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * The test media bundle. |
|
| 37 | - * |
|
| 38 | - * @var \Drupal\media_entity\MediaBundleInterface |
|
| 39 | - */ |
|
| 40 | - protected $testBundle; |
|
| 35 | + /** |
|
| 36 | + * The test media bundle. |
|
| 37 | + * |
|
| 38 | + * @var \Drupal\media_entity\MediaBundleInterface |
|
| 39 | + */ |
|
| 40 | + protected $testBundle; |
|
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * {@inheritdoc} |
|
| 44 | - */ |
|
| 45 | - protected function setUp() { |
|
| 42 | + /** |
|
| 43 | + * {@inheritdoc} |
|
| 44 | + */ |
|
| 45 | + protected function setUp() { |
|
| 46 | 46 | parent::setUp(); |
| 47 | 47 | $this->testBundle = $this->container->get('entity.manager')->getStorage('media_bundle')->load('image'); |
| 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', |
|
| 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 | 57 | ]); |
| 58 | 58 | $this->drupalLogin($adminUser); |
| 59 | - } |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - /** |
|
| 62 | - * Tests image media bundle creation from config files. |
|
| 63 | - */ |
|
| 64 | - public function testMediaBundleCreationFromModule() { |
|
| 61 | + /** |
|
| 62 | + * Tests image media bundle creation from config files. |
|
| 63 | + */ |
|
| 64 | + public function testMediaBundleCreationFromModule() { |
|
| 65 | 65 | $type_configuration = [ |
| 66 | - 'source_field' => 'field_image', |
|
| 67 | - 'gather_exif' => FALSE, |
|
| 66 | + 'source_field' => 'field_image', |
|
| 67 | + 'gather_exif' => FALSE, |
|
| 68 | 68 | ]; |
| 69 | 69 | |
| 70 | 70 | $this->assertTrue((bool) $this->testBundle, 'The media bundle from default configuration has been created in the database.'); |
@@ -73,20 +73,20 @@ discard block |
||
| 73 | 73 | $this->assertEqual($this->testBundle->get('type'), 'image', '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 item creation and thumbnail. |
|
| 80 | - */ |
|
| 81 | - public function testMediaBundleItemCreation() { |
|
| 78 | + /** |
|
| 79 | + * Tests item creation and thumbnail. |
|
| 80 | + */ |
|
| 81 | + public function testMediaBundleItemCreation() { |
|
| 82 | 82 | // Define the media item name. |
| 83 | 83 | $name = $this->randomMachineName(); |
| 84 | 84 | $image_files = $this->drupalGetTestFiles('image'); |
| 85 | 85 | $testImage = current($image_files); |
| 86 | 86 | $file_path = $this->container->get('file_system')->realpath($testImage->uri); |
| 87 | 87 | $edit = [ |
| 88 | - 'name[0][value]' => $name, |
|
| 89 | - 'files[field_image_0]' => $file_path, |
|
| 88 | + 'name[0][value]' => $name, |
|
| 89 | + 'files[field_image_0]' => $file_path, |
|
| 90 | 90 | ]; |
| 91 | 91 | |
| 92 | 92 | // Save the image. |
@@ -105,6 +105,6 @@ discard block |
||
| 105 | 105 | $thumbnail = $image->thumbnail($media); |
| 106 | 106 | $default_thumbnail = $image->getDefaultThumbnail(); |
| 107 | 107 | $this->assertNotEqual($thumbnail, $default_thumbnail, "The thumbnail generated is different from the default thumbnail."); |
| 108 | - } |
|
| 108 | + } |
|
| 109 | 109 | |
| 110 | 110 | } |
@@ -10,59 +10,59 @@ discard block |
||
| 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', |
|
| 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 | 56 | ]); |
| 57 | 57 | $this->drupalLogin($adminUser); |
| 58 | - } |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | - /** |
|
| 61 | - * Tests gallery media bundle creation from config files. |
|
| 62 | - */ |
|
| 63 | - public function testMediaBundleCreationFromModule() { |
|
| 60 | + /** |
|
| 61 | + * Tests gallery media bundle creation from config files. |
|
| 62 | + */ |
|
| 63 | + public function testMediaBundleCreationFromModule() { |
|
| 64 | 64 | $type_configuration = [ |
| 65 | - 'source_field' => 'field_slide', |
|
| 65 | + 'source_field' => 'field_slide', |
|
| 66 | 66 | ]; |
| 67 | 67 | |
| 68 | 68 | $this->assertTrue((bool) $this->testBundle, 'The media bundle from default configuration has been created in the database.'); |
@@ -71,21 +71,21 @@ discard block |
||
| 71 | 71 | $this->assertEqual($this->testBundle->get('type'), 'slideshow', 'Correct plugin ID detected.'); |
| 72 | 72 | $this->assertEqual($this->testBundle->get('type_configuration'), $type_configuration, 'Type configuration correct.'); |
| 73 | 73 | $this->assertEqual($this->testBundle->get('field_map'), [], 'Correct field map detected.'); |
| 74 | - } |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | - /** |
|
| 77 | - * Tests thumbnail of the gallery item. |
|
| 78 | - */ |
|
| 79 | - public function testGalleryItemThumbnail() { |
|
| 76 | + /** |
|
| 77 | + * Tests thumbnail of the gallery item. |
|
| 78 | + */ |
|
| 79 | + public function testGalleryItemThumbnail() { |
|
| 80 | 80 | // Let's add one image and one video. |
| 81 | 81 | $imageItem = $this->addImageItem(); |
| 82 | 82 | $videoItem = $this->addVideoItem(); |
| 83 | 83 | |
| 84 | 84 | $this->drupalGet('media/add/gallery'); |
| 85 | 85 | $edit = [ |
| 86 | - 'name[0][value]' => 'Gallery item', |
|
| 87 | - 'field_slide[0][target_id]' => $imageItem['name[0][value]'] . ' (' . $imageItem['id'] . ')', |
|
| 88 | - 'field_slide[0][_weight]' => 0, |
|
| 86 | + 'name[0][value]' => 'Gallery item', |
|
| 87 | + 'field_slide[0][target_id]' => $imageItem['name[0][value]'] . ' (' . $imageItem['id'] . ')', |
|
| 88 | + 'field_slide[0][_weight]' => 0, |
|
| 89 | 89 | ]; |
| 90 | 90 | $this->drupalPostAjaxForm(NULL, $edit, 'field_slide_add_more'); |
| 91 | 91 | $edit['field_slide[1][target_id]'] = $videoItem['name[0][value]'] . ' (' . $videoItem['id'] . ')'; |
@@ -105,9 +105,9 @@ discard block |
||
| 105 | 105 | |
| 106 | 106 | $this->drupalGet('media/add/gallery'); |
| 107 | 107 | $edit = [ |
| 108 | - 'name[0][value]' => 'Gallery item 2', |
|
| 109 | - 'field_slide[0][target_id]' => $videoItem['name[0][value]'] . ' (' . $videoItem['id'] . ')', |
|
| 110 | - 'field_slide[0][_weight]' => 0, |
|
| 108 | + 'name[0][value]' => 'Gallery item 2', |
|
| 109 | + 'field_slide[0][target_id]' => $videoItem['name[0][value]'] . ' (' . $videoItem['id'] . ')', |
|
| 110 | + 'field_slide[0][_weight]' => 0, |
|
| 111 | 111 | ]; |
| 112 | 112 | $this->drupalPostAjaxForm(NULL, $edit, 'field_slide_add_more'); |
| 113 | 113 | $edit['field_slide[1][target_id]'] = $imageItem['name[0][value]'] . ' (' . $imageItem['id'] . ')'; |
@@ -119,19 +119,19 @@ discard block |
||
| 119 | 119 | $gallery = $this->loadMediaItem(reset($gallery_id)); |
| 120 | 120 | $gallery_thumbnail = $gallery->getType()->thumbnail($gallery); |
| 121 | 121 | $this->assertEqual($gallery_thumbnail, $video_thumbnail, "Correct thumbnail detected."); |
| 122 | - } |
|
| 122 | + } |
|
| 123 | 123 | |
| 124 | - /** |
|
| 125 | - * Adds image type item. |
|
| 126 | - */ |
|
| 127 | - public function addImageItem() { |
|
| 124 | + /** |
|
| 125 | + * Adds image type item. |
|
| 126 | + */ |
|
| 127 | + public function addImageItem() { |
|
| 128 | 128 | // Let's add image first. |
| 129 | 129 | $name = $this->randomMachineName(); |
| 130 | 130 | $testImage = current($this->drupalGetTestFiles('image')); |
| 131 | 131 | $file_path = $this->container->get('file_system')->realpath($testImage->uri); |
| 132 | 132 | $edit = [ |
| 133 | - 'name[0][value]' => $name, |
|
| 134 | - 'files[field_image_0]' => $file_path, |
|
| 133 | + 'name[0][value]' => $name, |
|
| 134 | + 'files[field_image_0]' => $file_path, |
|
| 135 | 135 | ]; |
| 136 | 136 | // Save the image. |
| 137 | 137 | $this->drupalPostForm('media/add/image', $edit, t('Save and publish')); |
@@ -142,15 +142,15 @@ discard block |
||
| 142 | 142 | $edit['id'] = $media_id; |
| 143 | 143 | |
| 144 | 144 | return $edit; |
| 145 | - } |
|
| 145 | + } |
|
| 146 | 146 | |
| 147 | - /** |
|
| 148 | - * Adds video type item. |
|
| 149 | - */ |
|
| 150 | - public function addVideoItem() { |
|
| 147 | + /** |
|
| 148 | + * Adds video type item. |
|
| 149 | + */ |
|
| 150 | + public function addVideoItem() { |
|
| 151 | 151 | $edit = [ |
| 152 | - 'name[0][value]' => 'Drupal video!', |
|
| 153 | - 'field_video[0][value]' => 'https://www.youtube.com/watch?v=XgYu7-DQjDQ', |
|
| 152 | + 'name[0][value]' => 'Drupal video!', |
|
| 153 | + 'field_video[0][value]' => 'https://www.youtube.com/watch?v=XgYu7-DQjDQ', |
|
| 154 | 154 | ]; |
| 155 | 155 | $this->drupalPostForm('media/add/video', $edit, t('Save and publish')); |
| 156 | 156 | // Obtain the video id. |
@@ -159,22 +159,22 @@ discard block |
||
| 159 | 159 | $edit['id'] = $media_id; |
| 160 | 160 | |
| 161 | 161 | return $edit; |
| 162 | - } |
|
| 163 | - |
|
| 164 | - /** |
|
| 165 | - * Loads the media entity item. |
|
| 166 | - * |
|
| 167 | - * @param int $id |
|
| 168 | - * The id of the item. |
|
| 169 | - * |
|
| 170 | - * @return \Drupal\media_entity\MediaInterface |
|
| 171 | - * The media entity item. |
|
| 172 | - */ |
|
| 173 | - public function loadMediaItem($id) { |
|
| 162 | + } |
|
| 163 | + |
|
| 164 | + /** |
|
| 165 | + * Loads the media entity item. |
|
| 166 | + * |
|
| 167 | + * @param int $id |
|
| 168 | + * The id of the item. |
|
| 169 | + * |
|
| 170 | + * @return \Drupal\media_entity\MediaInterface |
|
| 171 | + * The media entity item. |
|
| 172 | + */ |
|
| 173 | + public function loadMediaItem($id) { |
|
| 174 | 174 | $item = $this->container->get('entity_type.manager') |
| 175 | - ->getStorage('media') |
|
| 176 | - ->loadUnchanged($id); |
|
| 175 | + ->getStorage('media') |
|
| 176 | + ->loadUnchanged($id); |
|
| 177 | 177 | return $item; |
| 178 | - } |
|
| 178 | + } |
|
| 179 | 179 | |
| 180 | 180 | } |