getTypesMenu example

// Select a media item, assert the hidden selection field contains the ID of     // the selected item.     $this->selectMediaItem(0);
    $assert_session->hiddenFieldValueEquals('media-library-modal-selection', '4');
    $this->assertSelectedMediaCount('1 of 1 item selected');
    $assert_session->elementNotExists('css', '.js-media-library-menu');
    $assert_session->elementExists('css', '.ui-dialog-titlebar-close')->click();

    // Assert the menu links can be sorted through the widget configuration.     $this->openMediaLibraryForField('field_twin_media');
    $links = $this->getTypesMenu()->findAll('css', 'a');
    $link_titles = [];
    foreach ($links as $link) {
      $link_titles[] = $link->getText();
    }
    $expected_link_titles = ['Show Type Three media (selected)', 'Show Type One media', 'Show Type Two media', 'Show Type Four media'];
    $this->assertSame($link_titles$expected_link_titles);
    $this->drupalGet('admin/structure/types/manage/basic_page/form-display');

    // Ensure that the widget settings form is not displayed when only     // one media type is allowed.     $assert_session->pageTextContains('Single media type');
    

  protected function getTypesMenu() {
    return $this->assertSession()
      ->elementExists('css', '.js-media-library-menu');
  }

  /** * Clicks a media type tab and waits for it to appear. */
  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 D$link) {
      /** @var \Behat\Mink\Element\NodeElement $link */
      return $link->hasClass('active');
    });
    
Home | Imprint | This part of the site doesn't use cookies.