You are here

public function MediaBrowserTest::testAccess in Lightning Media 8.3

Tests access to the media browser.

File

tests/src/Functional/MediaBrowserTest.php, line 58

Class

MediaBrowserTest
Tests the functionality of the media browser.

Namespace

Drupal\Tests\lightning_media\Functional

Code

public function testAccess() {
  $assert_session = $this
    ->assertSession();
  $account = $this
    ->drupalCreateUser([
    'access media_browser entity browser pages',
  ]);
  $this
    ->drupalLogin($account);
  $this
    ->drupalGet('/entity-browser/modal/media_browser');
  $assert_session
    ->statusCodeEquals(200);
  $assert_session
    ->pageTextContains('No widgets are available.');

  // Create a media type. There should still be no widgets available, since
  // the current user does not have permission to create media.
  $this
    ->createMediaType('image');
  $this
    ->getSession()
    ->reload();
  $assert_session
    ->statusCodeEquals(200);
  $assert_session
    ->pageTextContains('No widgets are available.');
  $account = $this
    ->drupalCreateUser([
    'access media_browser entity browser pages',
    'create media',
  ]);
  $this
    ->drupalLogin($account);
  $this
    ->drupalGet('/entity-browser/modal/media_browser');
  $assert_session
    ->statusCodeEquals(200);
  $assert_session
    ->pageTextNotContains('No widgets are available.');
  $assert_session
    ->buttonExists('Upload');
  $assert_session
    ->buttonExists('Create embed');
}