Commit 3e2d4340 authored by Gábor Hojtsy's avatar Gábor Hojtsy

Issue #2883813 by chr.fritsch, Wim Leers, Berdir, phenaproxima, catch: Move...

Issue #2883813 by chr.fritsch, Wim Leers, Berdir, phenaproxima, catch: Move File/Image media type into Standard once Media is stable
parent 50caae08
......@@ -50,7 +50,7 @@ protected function getExpectedNormalizedEntity() {
'type' => [
'href' => $this->baseUrl . '/rest/type/media/camelids',
],
$this->baseUrl . '/rest/relation/media/camelids/field_media_file_1' => [
$this->baseUrl . '/rest/relation/media/camelids/field_media_file' => [
[
'href' => $file->url(),
'lang' => 'en',
......@@ -75,7 +75,7 @@ protected function getExpectedNormalizedEntity() {
],
],
'_embedded' => [
$this->baseUrl . '/rest/relation/media/camelids/field_media_file_1' => [
$this->baseUrl . '/rest/relation/media/camelids/field_media_file' => [
[
'_links' => [
'self' => [
......
......@@ -5,4 +5,5 @@ core: 8.x
package: Testing
version: VERSION
dependencies:
- media
- media_test_source
......@@ -45,6 +45,7 @@ protected function createMediaType(array $values = [], $source = 'test') {
$this->assertIdentical(SAVED_NEW, $status, 'Media type was created successfully.');
// Ensure that the source field exists.
/** @var \Drupal\media\MediaSourceInterface $source */
$source = $media_type->getSource();
$source_field = $source->getSourceFieldDefinition($media_type);
if (!$source_field) {
......@@ -61,6 +62,11 @@ protected function createMediaType(array $values = [], $source = 'test') {
->save();
}
// Move source field in form display.
entity_get_form_display('media', $id, 'default')
->setComponent($source_field->getName())
->save();
return $media_type;
}
......
......@@ -80,6 +80,8 @@ public function testFileMediaRevision() {
$uri = 'temporary://foo.txt';
file_put_contents($uri, $this->randomString(128));
$this->createMediaType(['bundle' => 'file', 'new_revision' => TRUE], 'file');
// Create a media item.
$this->drupalGet('/media/add/file');
$page = $this->getSession()->getPage();
......@@ -117,6 +119,8 @@ public function testFileMediaRevision() {
public function testImageMediaRevision() {
$assert = $this->assertSession();
$this->createMediaType(['bundle' => 'image', 'new_revision' => TRUE], 'image');
/** @var \Drupal\field\FieldConfigInterface $field */
// Disable the alt text field, because this is not a JavaScript test and
// the alt text field will therefore not appear without a full page refresh.
......
......@@ -3,7 +3,6 @@
namespace Drupal\Tests\media\Functional;
use Drupal\field\Entity\FieldConfig;
use Drupal\media\Entity\MediaType;
/**
* Tests the file media source.
......@@ -12,17 +11,6 @@
*/
class MediaSourceFileTest extends MediaFunctionalTestBase {
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
// We need to test without any default configuration in place.
// @TODO: Remove this as part of https://www.drupal.org/node/2883813.
MediaType::load('file')->delete();
}
/**
* Test that it's possible to change the allowed file extensions.
*/
......
......@@ -3,7 +3,6 @@
namespace Drupal\Tests\media\Functional;
use Drupal\media\Entity\Media;
use Drupal\media\Entity\MediaType;
/**
* Ensures that media UI works correctly.
......@@ -29,11 +28,6 @@ protected function setUp() {
parent::setUp();
$this->drupalPlaceBlock('local_actions_block');
$this->drupalPlaceBlock('local_tasks_block');
// We need to test without any default configuration in place.
// @TODO: Remove this when https://www.drupal.org/node/2883813 lands.
MediaType::load('file')->delete();
MediaType::load('image')->delete();
}
/**
......@@ -59,6 +53,8 @@ public function testMediaWithOnlyOneMediaType() {
$page->fillField('name[0][value]', $media_name);
$revision_log_message = $this->randomString();
$page->fillField('revision_log_message[0][value]', $revision_log_message);
$source_field = $this->randomString();
$page->fillField('field_media_test[0][value]', $source_field);
$page->pressButton('Save');
$media_id = $this->container->get('entity.query')->get('media')->execute();
$media_id = reset($media_id);
......
......@@ -3,7 +3,6 @@
namespace Drupal\Tests\media\FunctionalJavascript;
use Drupal\media\Entity\Media;
use Drupal\media\Entity\MediaType;
/**
* Tests the file media source.
......@@ -12,17 +11,6 @@
*/
class MediaSourceFileTest extends MediaSourceTestBase {
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
// We need to test without any default configuration in place.
// @TODO: Remove this as part of https://www.drupal.org/node/2883813.
MediaType::load('file')->delete();
}
/**
* Tests the file media source.
*/
......
......@@ -3,7 +3,6 @@
namespace Drupal\Tests\media\FunctionalJavascript;
use Drupal\media\Entity\Media;
use Drupal\media\Entity\MediaType;
use Drupal\media\Plugin\media\Source\Image;
/**
......@@ -13,18 +12,6 @@
*/
class MediaSourceImageTest extends MediaSourceTestBase {
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
// We need to test without any default configuration in place.
// @TODO: Remove this as part of https://www.drupal.org/node/2883813.
MediaType::load('file')->delete();
MediaType::load('image')->delete();
}
/**
* Tests the image media source.
*/
......
......@@ -38,11 +38,6 @@ protected function setUp() {
parent::setUp();
$this->drupalPlaceBlock('local_actions_block');
$this->drupalPlaceBlock('local_tasks_block');
// We need to test without any default configuration in place.
// @TODO: Remove this as part of https://www.drupal.org/node/2883813.
MediaType::load('file')->delete();
MediaType::load('image')->delete();
}
/**
......
......@@ -22,6 +22,8 @@ public function testMediaWizard() {
$page = $session->getPage();
$assert_session = $this->assertSession();
$this->createMediaType();
$view_id = strtolower($this->randomMachineName(16));
$this->drupalGet('admin/structure/views/add');
$page->fillField('label', $view_id);
......
......@@ -2,8 +2,6 @@
namespace Drupal\Tests\media\Kernel;
use Drupal\media\Entity\MediaType;
/**
* Tests the file media source.
*
......@@ -11,18 +9,6 @@
*/
class MediaSourceFileTest extends MediaKernelTestBase {
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
// We need to test without any default configuration in place.
// @TODO: Remove this as part of https://www.drupal.org/node/2883813.
MediaType::load('file')->delete();
MediaType::load('image')->delete();
}
/**
* Tests the file extension constraint.
*/
......
......@@ -92,7 +92,7 @@ protected function createEntity() {
// Create a "Llama" media item.
$media = Media::create([
'bundle' => 'camelids',
'field_media_file_1' => [
'field_media_file' => [
'target_id' => $file->id(),
],
]);
......@@ -147,7 +147,7 @@ protected function getExpectedNormalizedEntity() {
'value' => 'Llama',
],
],
'field_media_file_1' => [
'field_media_file' => [
[
'description' => NULL,
'display' => NULL,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment