You are here

function ProfileCrudTest::testOverview in Linkit 8.4

Test the overview page.

File

src/Tests/ProfileCrudTest.php, line 31
Contains \Drupal\linkit\Tests\ProfileCreationTest.

Class

ProfileCrudTest
Tests creating, loading and deleting profiles.

Namespace

Drupal\linkit\Tests

Code

function testOverview() {

  // Verify that the profile collection page is not accessible for regular
  // users.
  $this
    ->drupalLogin($this->baseUser);
  $this
    ->drupalGet(Url::fromRoute('entity.linkit_profile.collection'));
  $this
    ->assertResponse(403);
  $this
    ->drupalLogout();

  // Verify that the profile collection page is accessible for regular users.
  $this
    ->drupalLogin($this->adminUser);
  $profiles = [];
  $profiles[] = $this
    ->createProfile();
  $profiles[] = $this
    ->createProfile();
  $this
    ->drupalGet(Url::fromRoute('entity.linkit_profile.collection'));
  $this
    ->assertResponse(200);

  // Assert that the 'Add profile' action exists.
  $this
    ->assertLinkByHref(Url::fromRoute('entity.linkit_profile.add_form')
    ->toString());

  /** @var \Drupal\linkit\ProfileInterface $profile */
  foreach ($profiles as $profile) {
    $this
      ->assertLinkByHref('admin/config/content/linkit/manage/' . $profile
      ->id());
    $this
      ->assertLinkByHref('admin/config/content/linkit/manage/' . $profile
      ->id() . '/delete');
  }
}