function WidgetOverflowTest::testUnlimitedCardinality

Same name in other branches
  1. 10 core/modules/media_library/tests/src/FunctionalJavascript/WidgetOverflowTest.php \Drupal\Tests\media_library\FunctionalJavascript\WidgetOverflowTest::testUnlimitedCardinality()

Tests that unlimited fields' selection count is not constrained.

@dataProvider providerWidgetOverflow

Parameters

string|null $selected_operation: The operation of the button to click. For example, if this is "insert", the "Save and insert" button will be pressed. If NULL, the "Save" button will be pressed.

File

core/modules/media_library/tests/src/FunctionalJavascript/WidgetOverflowTest.php, line 145

Class

WidgetOverflowTest
Tests that uploads in the 'media_library_widget' works as expected.

Namespace

Drupal\Tests\media_library\FunctionalJavascript

Code

public function testUnlimitedCardinality(?string $selected_operation) : void {
    if ($selected_operation) {
        $this->config('media_library.settings')
            ->set('advanced_ui', TRUE)
            ->save();
    }
    $assert_session = $this->assertSession();
    // Visit a node create page and open the media library.
    $this->drupalGet('node/add/basic_page');
    $this->openMediaLibraryForField('field_unlimited_media');
    $this->switchToMediaType('Three');
    $this->uploadFiles(5);
    if ($selected_operation) {
        $this->saveAnd($selected_operation);
    }
    else {
        $this->pressSaveButton();
    }
    if ($selected_operation !== 'insert') {
        $this->pressInsertSelected();
    }
    // There should not be any warnings or errors.
    $assert_session->elementNotExists('css', '.messages--error');
    $assert_session->elementNotExists('css', '.messages--warning');
    $this->waitForText('Added 5 media items.');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.