You are here

public function FieldUIRouteTest::testFieldUIRoutes in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/modules/field_ui/src/Tests/FieldUIRouteTest.php \Drupal\field_ui\Tests\FieldUIRouteTest::testFieldUIRoutes()

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

File

core/modules/field_ui/src/Tests/FieldUIRouteTest.php, line 41
Contains \Drupal\field_ui\Tests\FieldUIRouteTest.

Class

FieldUIRouteTest
Tests the functionality of the Field UI route subscriber.

Namespace

Drupal\field_ui\Tests

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
    ->assertResponse(403);
  $this
    ->drupalGet('admin/config/people/accounts/display');
  $this
    ->assertTitle('Manage display | Drupal');
  $this
    ->assertLocalTasks();
  $edit = array(
    '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
    ->assertResponse(403);
  $this
    ->drupalGet('admin/config/people/accounts/form-display');
  $this
    ->assertTitle('Manage form display | Drupal');
  $this
    ->assertLocalTasks();
  $edit = array(
    'display_modes_custom[register]' => TRUE,
  );
  $this
    ->drupalPostForm(NULL, $edit, t('Save'));
  $this
    ->assertResponse(200);
  $this
    ->drupalGet('admin/config/people/accounts/form-display/register');
  $this
    ->assertTitle('Manage form display | Drupal');
  $this
    ->assertLocalTasks();
  $this
    ->assert(count($this
    ->xpath('//ul/li[1]/a[contains(text(), :text)]', array(
    ':text' => 'Default',
  ))) == 1, '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(array(
    'id' => 'user.test',
    'label' => 'Test',
    'targetEntityType' => 'user',
  ))
    ->save();
  $this->container
    ->get('router.builder')
    ->rebuildIfNeeded();
  $edit = array(
    'display_modes_custom[test]' => TRUE,
  );
  $this
    ->drupalPostForm('admin/config/people/accounts/display', $edit, t('Save'));
  $this
    ->assertLink('Test');

  // Create new form mode and verify it's available on the Manage Form
  // Display screen after enabling it.
  EntityFormMode::create(array(
    'id' => 'user.test',
    'label' => 'Test',
    'targetEntityType' => 'user',
  ))
    ->save();
  $this->container
    ->get('router.builder')
    ->rebuildIfNeeded();
  $edit = array(
    'display_modes_custom[test]' => TRUE,
  );
  $this
    ->drupalPostForm('admin/config/people/accounts/form-display', $edit, t('Save'));
  $this
    ->assertLink('Test');
}