You are here

public function DeveloperAppUITest::testBreadcrumbOnDeveloperAppPages in Apigee Edge 8

Ensures breadcrumb is properly displayed on the developer app pages.

File

tests/src/Functional/DeveloperAppUITest.php, line 600

Class

DeveloperAppUITest
Developer app UI tests.

Namespace

Drupal\Tests\apigee_edge\Functional

Code

public function testBreadcrumbOnDeveloperAppPages() {
  $this
    ->drupalLogin($this->rootUser);
  $user = $this
    ->createAccount();

  // Check UID 2 Apps page.
  $this
    ->drupalGet(Url::fromRoute('entity.developer_app.collection_by_developer', [
    'user' => $this->account
      ->id(),
  ]));
  $breadcrumb_links = $this
    ->getBreadcrumbLinks();
  $this
    ->assertEquals('/', $breadcrumb_links[0]
    ->getAttribute('href'));
  $this
    ->assertEquals(Url::fromRoute('entity.user.canonical', [
    'user' => $this->account
      ->id(),
  ])
    ->toString(), $breadcrumb_links[1]
    ->getAttribute('href'));

  // Check UID 2 create app page.
  $this
    ->drupalGet(Url::fromRoute('entity.developer_app.add_form_for_developer', [
    'user' => $this->account
      ->id(),
  ]));
  $breadcrumb_links = $this
    ->getBreadcrumbLinks();
  $this
    ->assertEquals('/', $breadcrumb_links[0]
    ->getAttribute('href'));
  $this
    ->assertEquals(Url::fromRoute('entity.user.canonical', [
    'user' => $this->account
      ->id(),
  ])
    ->toString(), $breadcrumb_links[1]
    ->getAttribute('href'));
  $this
    ->assertEquals(Url::fromRoute('entity.developer_app.collection_by_developer', [
    'user' => $this->account
      ->id(),
  ])
    ->toString(), $breadcrumb_links[2]
    ->getAttribute('href'));

  // Check UID 3 apps page.
  $this
    ->drupalGet(Url::fromRoute('entity.developer_app.collection_by_developer', [
    'user' => $user
      ->id(),
  ]));
  $breadcrumb_links = $this
    ->getBreadcrumbLinks();
  $this
    ->assertEquals('/', $breadcrumb_links[0]
    ->getAttribute('href'));
  $this
    ->assertEquals(Url::fromRoute('entity.user.canonical', [
    'user' => $user
      ->id(),
  ])
    ->toString(), $breadcrumb_links[1]
    ->getAttribute('href'));

  // Check UID 3 create app page.
  $this
    ->drupalGet(Url::fromRoute('entity.developer_app.add_form_for_developer', [
    'user' => $user
      ->id(),
  ]));
  $expected_breadcrumb[] = Url::fromRoute('entity.developer_app.collection_by_developer', [
    'user' => $user
      ->id(),
  ])
    ->toString();
  $breadcrumb_links = $this
    ->getBreadcrumbLinks();
  $this
    ->assertEquals('/', $breadcrumb_links[0]
    ->getAttribute('href'));
  $this
    ->assertEquals(Url::fromRoute('entity.user.canonical', [
    'user' => $user
      ->id(),
  ])
    ->toString(), $breadcrumb_links[1]
    ->getAttribute('href'));
  $this
    ->assertEquals(Url::fromRoute('entity.developer_app.collection_by_developer', [
    'user' => $user
      ->id(),
  ])
    ->toString(), $breadcrumb_links[2]
    ->getAttribute('href'));
}