You are here

protected function IndependentScheduledUpdateTypeTest::checkAddForm in Scheduled Updates 8

Check that the Scheduled Update add form is correct.

Parameters

$type_id:

$label:

$fields:

$only_type:

Throws

\Exception

1 call to IndependentScheduledUpdateTypeTest::checkAddForm()
IndependentScheduledUpdateTypeTest::testCreateMultiTypes in tests/src/FunctionalJavascript/IndependentScheduledUpdateTypeTest.php

File

tests/src/FunctionalJavascript/IndependentScheduledUpdateTypeTest.php, line 76
Contains \Drupal\Tests\scheduled_updates\IndependentScheduledUpdateTypeTest.

Class

IndependentScheduledUpdateTypeTest
Test adding an Independent Scheduled Update Type.

Namespace

Drupal\Tests\scheduled_updates\FunctionalJavascript

Code

protected function checkAddForm($type_id, $label, $fields, $only_type) {
  $this
    ->loginWithPermissions([
    "create {$type_id} scheduled updates",
  ]);
  $this
    ->drupalGet('admin/content/scheduled-update/add');
  if ($only_type) {

    // Form shown if only type.
    $this
      ->checkFieldLabels($fields);
  }
  else {
    $this
      ->assertSession()
      ->pageTextContains($label);

    /** @var ScheduledUpdateType[] $types */
    $types = ScheduledUpdateType::loadMultiple();

    // Check that all types are shown on the add page.
    foreach ($types as $type) {
      $this
        ->assertSession()
        ->pageTextContains($type
        ->label());
    }
  }

  //$this->assertSession()->pageTextContains($label);
  $this
    ->drupalGet("admin/content/scheduled-update/add/{$type_id}");
  $this
    ->assertSession()
    ->pageTextContains(new FormattableMarkup('Create @label Scheduled Update', [
    '@label' => $label,
  ]));
  $this
    ->checkFieldLabels($fields);
  $this
    ->loginLastUser();
}