You are here

public function BreadcrumbExtraFieldTest::testAdminUi in Breadcrumb Extra Field 8

Same name and namespace in other branches
  1. 2.x tests/src/Functional/BreadcrumbExtraFieldTest.php \Drupal\Tests\breadcrumb_extra_field\Functional\BreadcrumbExtraFieldTest::testAdminUi()

Tests that the admin UI configuration options works.

File

tests/src/Functional/BreadcrumbExtraFieldTest.php, line 44

Class

BreadcrumbExtraFieldTest
Tests for breadcrumb extra field.

Namespace

Drupal\Tests\breadcrumb_extra_field\Functional

Code

public function testAdminUi() {

  // Check not allowed access.
  $account = $this
    ->drupalCreateUser();
  $this
    ->drupalLogin($account);
  $this
    ->drupalGet('admin/config/system/breadcrumb-extra-field');
  $this
    ->assertSession()
    ->statusCodeEquals(403);
  $this
    ->drupalLogout();
  $account = $this
    ->drupalCreateUser([
    'administer breadcrumb extra field',
  ], NULL, TRUE);
  $this
    ->drupalLogin($account);

  // Check extra field visibility before configuration.
  $this
    ->drupalGet('admin/structure/types/manage/article/display');
  $this
    ->assertSession()
    ->elementNotExists('xpath', '//tr[@data-drupal-selector="edit-fields-breadcrumb"]');

  // Check allowed access.
  $this
    ->drupalGet('admin/config/system/breadcrumb-extra-field');
  $this
    ->assertSession()
    ->statusCodeEquals(200);

  // Check field to created content type.
  $this
    ->assertSession()
    ->fieldExists('Article');

  // Enable to articles.
  $this
    ->submitForm([
    'Article' => TRUE,
  ], 'Save configuration');

  // Clear cache required.
  $this
    ->resetAll();

  // Check extra field visibility after configuration.
  $this
    ->drupalGet('admin/structure/types/manage/article/display');
  $this
    ->assertSession()
    ->elementExists('xpath', '//tr[@data-drupal-selector="edit-fields-breadcrumb"]');

  // Check label.
  $this
    ->assertSession()
    ->elementTextContains('css', '.entity-view-display-edit-form', 'Breadcrumb');
}