You are here

protected function ScheduledUpdatesTestBase::createType in Scheduled Updates 8

Parameters

$label:

$id:

array $clone_fields:

array $type_options:

Throws

\Exception

1 call to ScheduledUpdatesTestBase::createType()
IndependentScheduledUpdateTypeTest::createType in tests/src/FunctionalJavascript/IndependentScheduledUpdateTypeTest.php
2 methods override ScheduledUpdatesTestBase::createType()
EmbeddedScheduledUpdateTypeTest::createType in tests/src/FunctionalJavascript/EmbeddedScheduledUpdateTypeTest.php
Create a scheduled update type via the UI.
IndependentScheduledUpdateTypeTest::createType in tests/src/FunctionalJavascript/IndependentScheduledUpdateTypeTest.php

File

tests/src/FunctionalJavascript/ScheduledUpdatesTestBase.php, line 153
Contains \Drupal\Tests\scheduled_updates\ScheduledUpdatesTestBase.

Class

ScheduledUpdatesTestBase
Define base class for Scheduled Updates Tests

Namespace

Drupal\Tests\scheduled_updates\FunctionalJavascript

Code

protected function createType($label, $id, array $clone_fields, $type_options = []) {
  $this
    ->drupalGet('admin/config/workflow/scheduled-update-type/add');

  // Revision options should not be displayed until entity type that supports it is selected.
  $this
    ->assertSession()
    ->pageTextNotContains('The owner of the last revision.');
  $this
    ->assertSession()
    ->pageTextNotContains('Create New Revisions');
  $edit = $type_options + [
    'label' => $label,
    'id' => $id,
    'update_entity_type' => 'node',
    'update_runner[id]' => 'default_independent',
    'update_runner[after_run]' => UpdateRunnerInterface::AFTER_DELETE,
    'update_runner[invalid_update_behavior]' => UpdateRunnerInterface::INVALID_DELETE,
    'update_runner[update_user]' => UpdateRunnerInterface::USER_UPDATE_RUNNER,
  ];
  $this
    ->checkRunnersAvailable();
  $this
    ->drupalPostAjaxForm(NULL, $edit, 'update_entity_type');
  $this
    ->assertSession()
    ->pageTextContains('The owner of the last revision.');
  $this
    ->assertSession()
    ->pageTextContains('Create New Revisions');
  $edit = $type_options + [
    'label' => $label,
    'id' => $id,
    'clone_field' => 'multiple-field',
    'update_entity_type' => 'node',
    'update_runner[id]' => 'default_independent',
    'update_runner[after_run]' => UpdateRunnerInterface::AFTER_DELETE,
    'update_runner[invalid_update_behavior]' => UpdateRunnerInterface::INVALID_DELETE,
    'update_runner[update_user]' => UpdateRunnerInterface::USER_UPDATE_RUNNER,
    'update_runner[create_revisions]' => UpdateRunnerInterface::REVISIONS_YES,
    'update_runner[bundles][article]' => 'article',
  ];
  $this
    ->drupalPostForm(NULL, $edit, t('Save'));
  $this
    ->assertUrl("admin/config/workflow/scheduled-update-type/{$id}/clone-fields");
  $this
    ->assertSession()
    ->pageTextContains("Created the {$label} Scheduled Update Type.");
  $this
    ->assertSession()
    ->pageTextContains("Select fields to add to these updates");
  $this
    ->checkExpectedCheckboxes('base_fields', $this
    ->getNodePropertyMachineNames());

  // @todo test that node.body displays and is select field.
  $this
    ->cloneFields($id, $clone_fields);
}