function MediaLibraryTestBase::switchToMediaType

Same name in other branches
  1. 9 core/modules/media_library/tests/src/FunctionalJavascript/MediaLibraryTestBase.php \Drupal\Tests\media_library\FunctionalJavascript\MediaLibraryTestBase::switchToMediaType()
  2. 10 core/modules/media_library/tests/src/FunctionalJavascript/MediaLibraryTestBase.php \Drupal\Tests\media_library\FunctionalJavascript\MediaLibraryTestBase::switchToMediaType()
  3. 11.x core/modules/media_library/tests/src/FunctionalJavascript/MediaLibraryTestBase.php \Drupal\Tests\media_library\FunctionalJavascript\MediaLibraryTestBase::switchToMediaType()

Clicks a media type tab and waits for it to appear.

5 calls to MediaLibraryTestBase::switchToMediaType()
EntityReferenceWidgetTest::testWidget in core/modules/media_library/tests/src/FunctionalJavascript/EntityReferenceWidgetTest.php
Tests that the Media library's widget works as expected.
WidgetOEmbedTest::testWidgetOEmbed in core/modules/media_library/tests/src/FunctionalJavascript/WidgetOEmbedTest.php
Tests that oEmbed media can be added in the Media library's widget.
WidgetOEmbedTest::testWidgetOEmbedAdvancedUi in core/modules/media_library/tests/src/FunctionalJavascript/WidgetOEmbedTest.php
Tests that oEmbed media can be added in the widget's advanced UI.
WidgetUploadTest::testWidgetUpload in core/modules/media_library/tests/src/FunctionalJavascript/WidgetUploadTest.php
Tests that uploads in the Media library's widget works as expected.
WidgetUploadTest::testWidgetUploadAdvancedUi in core/modules/media_library/tests/src/FunctionalJavascript/WidgetUploadTest.php
Tests that uploads in the widget's advanced UI works as expected.

File

core/modules/media_library/tests/src/FunctionalJavascript/MediaLibraryTestBase.php, line 175

Class

MediaLibraryTestBase
Base class for functional tests of Media Library functionality.

Namespace

Drupal\Tests\media_library\FunctionalJavascript

Code

protected function switchToMediaType($type) {
    $link = $this->assertSession()
        ->elementExists('named', [
        'link',
        "Type {$type}",
    ], $this->getTypesMenu());
    if ($link->hasClass('active')) {
        // There is nothing to do as the type is already active.
        return;
    }
    $link->click();
    $result = $link->waitFor(10, function ($link) {
        
        /** @var \Behat\Mink\Element\NodeElement $link */
        return $link->hasClass('active');
    });
    $this->assertNotEmpty($result);
    // assertWaitOnAjaxRequest() required for input "id" attributes to
    // consistently match their label's "for" attribute.
    $this->assertSession()
        ->assertWaitOnAjaxRequest();
}

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