function FieldUIRouteTest::testFieldUIRoutes

Same name in other branches
  1. 9 core/modules/field_ui/tests/src/Functional/FieldUIRouteTest.php \Drupal\Tests\field_ui\Functional\FieldUIRouteTest::testFieldUIRoutes()
  2. 10 core/modules/field_ui/tests/src/Functional/FieldUIRouteTest.php \Drupal\Tests\field_ui\Functional\FieldUIRouteTest::testFieldUIRoutes()
  3. 11.x core/modules/field_ui/tests/src/Functional/FieldUIRouteTest.php \Drupal\Tests\field_ui\Functional\FieldUIRouteTest::testFieldUIRoutes()

Ensures that entity types with bundles do not break following entity types.

File

core/modules/field_ui/tests/src/Functional/FieldUIRouteTest.php, line 41

Class

FieldUIRouteTest
Tests the functionality of the Field UI route subscriber.

Namespace

Drupal\Tests\field_ui\Functional

Code

public function testFieldUIRoutes() {
    $this->drupalGet('entity_test_no_id/structure/entity_test/fields');
    $this->assertText('No fields are present yet.');
    $this->drupalGet('admin/config/people/accounts/fields');
    $this->assertTitle('Manage fields | Drupal');
    $this->assertLocalTasks();
    // Test manage display tabs and titles.
    $this->drupalGet('admin/config/people/accounts/display/compact');
    $this->assertSession()
        ->statusCodeEquals(403);
    $this->drupalGet('admin/config/people/accounts/display');
    $this->assertTitle('Manage display | Drupal');
    $this->assertLocalTasks();
    $edit = [
        'display_modes_custom[compact]' => TRUE,
    ];
    $this->drupalPostForm(NULL, $edit, t('Save'));
    $this->drupalGet('admin/config/people/accounts/display/compact');
    $this->assertTitle('Manage display | Drupal');
    $this->assertLocalTasks();
    // Test manage form display tabs and titles.
    $this->drupalGet('admin/config/people/accounts/form-display/register');
    $this->assertSession()
        ->statusCodeEquals(403);
    $this->drupalGet('admin/config/people/accounts/form-display');
    $this->assertTitle('Manage form display | Drupal');
    $this->assertLocalTasks();
    $edit = [
        'display_modes_custom[register]' => TRUE,
    ];
    $this->drupalPostForm(NULL, $edit, t('Save'));
    $this->assertSession()
        ->statusCodeEquals(200);
    $this->drupalGet('admin/config/people/accounts/form-display/register');
    $this->assertTitle('Manage form display | Drupal');
    $this->assertLocalTasks();
    $this->assertCount(1, $this->xpath('//ul/li[1]/a[contains(text(), :text)]', [
        ':text' => 'Default',
    ]), 'Default secondary tab is in first position.');
    // Create new view mode and verify it's available on the Manage Display
    // screen after enabling it.
    EntityViewMode::create([
        'id' => 'user.test',
        'label' => 'Test',
        'targetEntityType' => 'user',
    ])->save();
    $this->container
        ->get('router.builder')
        ->rebuildIfNeeded();
    $edit = [
        'display_modes_custom[test]' => TRUE,
    ];
    $this->drupalPostForm('admin/config/people/accounts/display', $edit, t('Save'));
    $this->assertSession()
        ->linkExists('Test');
    // Create new form mode and verify it's available on the Manage Form
    // Display screen after enabling it.
    EntityFormMode::create([
        'id' => 'user.test',
        'label' => 'Test',
        'targetEntityType' => 'user',
    ])->save();
    $this->container
        ->get('router.builder')
        ->rebuildIfNeeded();
    $edit = [
        'display_modes_custom[test]' => TRUE,
    ];
    $this->drupalPostForm('admin/config/people/accounts/form-display', $edit, t('Save'));
    $this->assertSession()
        ->linkExists('Test');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.