diff --git a/core/modules/media_library/js/media_library.ui.es6.js b/core/modules/media_library/js/media_library.ui.es6.js index d9c95c1d78..43c641153d 100644 --- a/core/modules/media_library/js/media_library.ui.es6.js +++ b/core/modules/media_library/js/media_library.ui.es6.js @@ -2,7 +2,7 @@ * @file media_library.widget.js */ (($, Drupal, window) => { - debugger; + /** * Wrapper object for the current state of the media library. */ diff --git a/core/modules/media_library/js/media_library.ui.js b/core/modules/media_library/js/media_library.ui.js index 44fafc4df5..663a4082b9 100644 --- a/core/modules/media_library/js/media_library.ui.js +++ b/core/modules/media_library/js/media_library.ui.js @@ -6,8 +6,6 @@ **/ (function ($, Drupal, window) { - debugger; - Drupal.MediaLibrary = { currentSelection: [], diff --git a/core/modules/media_library/tests/src/FunctionalJavascript/MediaLibraryTest.php b/core/modules/media_library/tests/src/FunctionalJavascript/MediaLibraryTest.php index 600c472ebc..06b7c20026 100644 --- a/core/modules/media_library/tests/src/FunctionalJavascript/MediaLibraryTest.php +++ b/core/modules/media_library/tests/src/FunctionalJavascript/MediaLibraryTest.php @@ -151,7 +151,7 @@ public function testWidgetAccess() { // Create a working state. $allowed_types = ['type_one', 'type_two']; - $state = MediaLibraryState::create('test', $allowed_types, 'type_two', 2); + $state = MediaLibraryState::create('test', $allowed_types, 'type_two', 2, TRUE); $url_options = ['query' => $state->all()]; // Verify that unprivileged users can't access the widget view. diff --git a/core/modules/media_library/tests/src/Kernel/MediaLibraryStateTest.php b/core/modules/media_library/tests/src/Kernel/MediaLibraryStateTest.php index 4491a3a6a6..b253a78b78 100644 --- a/core/modules/media_library/tests/src/Kernel/MediaLibraryStateTest.php +++ b/core/modules/media_library/tests/src/Kernel/MediaLibraryStateTest.php @@ -65,16 +65,19 @@ public function testMethods() { $allowed_media_type_ids = ['file', 'image']; $selected_media_type_id = 'image'; $remaining_slots = 2; + $return_created = TRUE; - $state = MediaLibraryState::create($opener_id, $allowed_media_type_ids, $selected_media_type_id, $remaining_slots); + $state = MediaLibraryState::create($opener_id, $allowed_media_type_ids, $selected_media_type_id, $remaining_slots, $return_created); $this->assertSame($opener_id, $state->getOpenerId()); $this->assertSame($allowed_media_type_ids, $state->getAllowedTypeIds()); $this->assertSame($selected_media_type_id, $state->getSelectedTypeId()); $this->assertSame($remaining_slots, $state->getAvailableSlots()); $this->assertTrue($state->hasSlotsAvailable()); + $this->assertTrue($state->shouldReturnCreated()); - $state = MediaLibraryState::create($opener_id, $allowed_media_type_ids, $selected_media_type_id, 0); + $state = MediaLibraryState::create($opener_id, $allowed_media_type_ids, $selected_media_type_id, 0, FALSE); $this->assertFalse($state->hasSlotsAvailable()); + $this->assertFalse($state->shouldReturnCreated()); } /** @@ -89,17 +92,20 @@ public function testMethods() { * @param int $remaining_slots * The number of remaining items the user is allowed to select or add in the * library. + * @param bool $return_created + * A flag indicating if created media should be directly returned to the + * opener or not. * @param string $exception_message * The expected exception message. * * @covers ::create * @dataProvider providerCreate */ - public function testCreate($opener_id, array $allowed_media_type_ids, $selected_type_id, $remaining_slots, $exception_message = '') { + public function testCreate($opener_id, array $allowed_media_type_ids, $selected_type_id, $remaining_slots, $return_created, $exception_message = '') { if ($exception_message) { $this->setExpectedException(\InvalidArgumentException::class, $exception_message); } - $state = MediaLibraryState::create($opener_id, $allowed_media_type_ids, $selected_type_id, $remaining_slots); + $state = MediaLibraryState::create($opener_id, $allowed_media_type_ids, $selected_type_id, $remaining_slots, $return_created); $this->assertInstanceOf(MediaLibraryState::class, $state); } @@ -118,6 +124,7 @@ public function providerCreate() { ['file', 'image'], 'image', 2, + TRUE, ]; // Assert an exception is thrown when the opener ID parameter is empty. @@ -126,6 +133,7 @@ public function providerCreate() { ['file', 'image'], 'image', 2, + TRUE, 'The opener ID parameter is required and must be a string.', ]; // Assert an exception is thrown when the opener ID parameter is not a @@ -135,6 +143,7 @@ public function providerCreate() { ['file', 'image'], 'image', 2, + TRUE, 'The opener ID parameter is required and must be a string.', ]; $test_data['boolean opener ID'] = [ @@ -142,6 +151,7 @@ public function providerCreate() { ['file', 'image'], 'image', 2, + TRUE, 'The opener ID parameter is required and must be a string.', ]; $test_data['spaces opener ID'] = [ @@ -149,6 +159,7 @@ public function providerCreate() { ['file', 'image'], 'image', 2, + TRUE, 'The opener ID parameter is required and must be a string.', ]; @@ -158,6 +169,7 @@ public function providerCreate() { [], 'image', 2, + TRUE, 'The allowed types parameter is required and must be an array of strings.', ]; // It is not possible to assert a non-array allowed types parameter, since @@ -169,6 +181,7 @@ public function providerCreate() { [1, 'image'], 'image', 2, + TRUE, 'The allowed types parameter is required and must be an array of strings.', ]; $test_data['boolean in allowed types'] = [ @@ -176,6 +189,7 @@ public function providerCreate() { [TRUE, 'image'], 'image', 2, + TRUE, 'The allowed types parameter is required and must be an array of strings.', ]; $test_data['spaces in allowed types'] = [ @@ -183,6 +197,7 @@ public function providerCreate() { [' ', 'image'], 'image', 2, + TRUE, 'The allowed types parameter is required and must be an array of strings.', ]; // Assert an exception is thrown when the allowed types parameter contains a @@ -192,6 +207,7 @@ public function providerCreate() { ['file', 'image', 'fail'], 'image', 2, + TRUE, 'The allowed types parameter contains an invalid media type.', ]; @@ -201,6 +217,7 @@ public function providerCreate() { ['file', 'image'], '', 2, + TRUE, 'The selected type parameter is required and must be a string.', ]; // Assert an exception is thrown when the selected type parameter is not a @@ -210,6 +227,7 @@ public function providerCreate() { ['file', 'image'], 1, 2, + TRUE, 'The selected type parameter is required and must be a string.', ]; $test_data['boolean selected type'] = [ @@ -217,6 +235,7 @@ public function providerCreate() { ['file', 'image'], TRUE, 2, + TRUE, 'The selected type parameter is required and must be a string.', ]; $test_data['spaces selected type'] = [ @@ -224,6 +243,7 @@ public function providerCreate() { ['file', 'image'], ' ', 2, + TRUE, 'The selected type parameter is required and must be a string.', ]; // Assert an exception is thrown when the selected type parameter is not in @@ -233,6 +253,7 @@ public function providerCreate() { ['file', 'image'], 'video', 2, + TRUE, 'The selected type parameter must be present in the list of allowed types.', ]; @@ -243,6 +264,7 @@ public function providerCreate() { ['file', 'image'], 'image', '', + TRUE, 'The remaining slots parameter is required and must be numeric.', ]; // Assert an exception is thrown when the remaining slots parameter is @@ -252,6 +274,7 @@ public function providerCreate() { ['file', 'image'], 'image', 'fail', + TRUE, 'The remaining slots parameter is required and must be numeric.', ]; $test_data['boolean remaining slots'] = [ @@ -259,6 +282,7 @@ public function providerCreate() { ['file', 'image'], 'image', TRUE, + TRUE, 'The remaining slots parameter is required and must be numeric.', ];