You are here

public function FormModeManagerRouteTest::testListWithTwoFormModeManagerRoutes in Form mode manager 8

Same name and namespace in other branches
  1. 8.2 tests/src/Functional/FormModeManagerRouteTest.php \Drupal\Tests\form_mode_manager\Functional\FormModeManagerRouteTest::testListWithTwoFormModeManagerRoutes()

Asserts List With Two Form Mode Manager routes exists.

File

tests/src/Functional/FormModeManagerRouteTest.php, line 208

Class

FormModeManagerRouteTest
Tests the routes generated by form_mode_manager.

Namespace

Drupal\Tests\form_mode_manager\Functional

Code

public function testListWithTwoFormModeManagerRoutes() {
  $node_form_mode_id = $this->formModeManager
    ->getFormModeMachineName($this->nodeFormMode
    ->id());
  $node_type_fmm2 = $this
    ->drupalCreateContentType([
    'name' => 'Form Mode Manager Test 2',
    'type' => 'fmm_test2',
  ]);
  Role::load($this->adminUser
    ->getRoles()[1])
    ->grantPermission('create ' . $node_type_fmm2
    ->id() . ' content')
    ->grantPermission('edit any ' . $node_type_fmm2
    ->id() . ' content')
    ->save();
  $this
    ->drupalLogin($this->adminUser);

  // Add a content type and attach it to form mode.
  $this
    ->drupalGet("admin/structure/types/manage/{$node_type_fmm2->id()}/form-display");
  $edit = [
    "display_modes_custom[{$node_form_mode_id}]" => TRUE,
  ];
  $this
    ->drupalPostForm("admin/structure/types/manage/{$node_type_fmm2->id()}/form-display", $edit, t('Save'));
  $this
    ->drupalGet("node/add-list/{$node_form_mode_id}");
  $this
    ->assertSession()
    ->linkExists($this->nodeTypeFmm1
    ->label());
  $this
    ->assertSession()
    ->linkExists($node_type_fmm2
    ->label());
  $this
    ->assertSession()
    ->statusCodeEquals(200);

  // List form mode not exit.
  $this
    ->drupalGet("node/add-list/not-valid-fm");
  $this
    ->assertSession()
    ->statusCodeEquals(404);
}