You are here

public function ParagraphListingTest::testParagraphListingPages in Paragraphs admin 8

Tests file overview with different user permissions.

File

tests/src/Functional/ParagraphListingTest.php, line 54

Class

ParagraphListingTest
Tests file listing page functionality.

Namespace

Drupal\Tests\paragraphs_admin\Functional

Code

public function testParagraphListingPages() {
  $this
    ->addParagraphsType('paragraphed_test');

  // Users without sufficient permissions should not see paragraph listing.
  $this
    ->drupalLogin($this->baseUser);
  $this
    ->drupalGet('admin/content/paragraphs');
  $this
    ->assertSession()
    ->statusCodeEquals(403);

  // Log in with user with right permissions and test listing.
  $this
    ->drupalLogin($this->adminUser);
  $this
    ->drupalGet('admin/content/paragraphs');
  $this
    ->assertSession()
    ->pageTextContains('Paragraphs');

  // Create a paragraph.
  $paragraph = $this
    ->createParagraph();
  $pid = $paragraph
    ->id();

  // Check paragraph exists.
  $delete_link = 'paragraph/' . $pid . '/delete';
  $this
    ->drupalGet('admin/content/paragraphs');
  $this
    ->assertSession()
    ->linkByHrefExists($delete_link);

  // Delete paragraph.
  $this
    ->drupalGet($delete_link);

  // Check that paragraph was deleted.
  $this
    ->assertSession()
    ->pageTextContains('Paragraph ' . $pid . ' deleted.');
  $this
    ->assertSession()
    ->linkByHrefNotExists($delete_link);
}