You are here

public function ProfileAdminTest::testOverview in Linkit 8.5

Test the overview page.

File

tests/src/Functional/ProfileAdminTest.php, line 19

Class

ProfileAdminTest
Tests creating, loading and deleting profiles.

Namespace

Drupal\Tests\linkit\Functional

Code

public function testOverview() {

  // Verify that the profile collection page is not accessible for users
  // without permission.
  $this
    ->drupalLogin($this->webUser);
  $this
    ->drupalGet('/admin/config/content/linkit');
  $this
    ->assertSession()
    ->statusCodeEquals(403);
  $this
    ->drupalLogout();

  // Login as an admin user and make sure the collection page is accessible.
  $this
    ->drupalLogin($this->adminUser);
  $this
    ->drupalGet('/admin/config/content/linkit');
  $this
    ->assertSession()
    ->statusCodeEquals(200);

  // Make sure the 'Add profile' action link is present.
  $this
    ->assertSession()
    ->linkByHrefExists('/admin/config/content/linkit/add');

  // Create multiple profiles.
  $profiles = [];
  $profiles[] = $this
    ->createProfile();
  $profiles[] = $this
    ->createProfile();

  // Refresh the page.
  $this
    ->drupalGet('/admin/config/content/linkit');
  $this
    ->assertSession()
    ->statusCodeEquals(200);

  // Make sure that there is an edit and a delete operation link for all
  // profiles.
  foreach ($profiles as $profile) {
    $this
      ->assertSession()
      ->linkByHrefExists('/admin/config/content/linkit/manage/' . $profile
      ->id());
    $this
      ->assertSession()
      ->linkByHrefExists('/admin/config/content/linkit/manage/' . $profile
      ->id() . '/delete');
  }
}