You are here

protected function IndependentScheduledUpdateTypeTest::checkRunningPromoteUpdates in Scheduled Updates 8

Checking adding and running updates.

Parameters

$id:

Throws

\Exception

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

File

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

Class

IndependentScheduledUpdateTypeTest
Test adding an Independent Scheduled Update Type.

Namespace

Drupal\Tests\scheduled_updates\FunctionalJavascript

Code

protected function checkRunningPromoteUpdates($id) {
  $this
    ->loginWithPermissions([
    "create {$id} scheduled updates",
    "edit own {$id} scheduled updates",
  ]);
  $page_node = $this
    ->drupalCreateNode([
    'promote' => NODE_NOT_PROMOTED,
  ]);
  $this
    ->gotoUpdateAdd($id);
  $edit = [
    'entity_ids[0][target_id]' => "{$page_node->label()} ({$page_node->id()})",
    'update_timestamp[0][value][date]' => $this
      ->getRelativeDate('-1 day'),
    'update_timestamp[0][value][time]' => '01:00:00',
    'field_promote[value]' => 1,
  ];
  $this
    ->drupalPostForm(NULL, $edit, 'Save');
  $this
    ->assertSession()
    ->pageTextContains('cannot be referenced.');
  $article_node = $this
    ->drupalCreateNode([
    'promote' => NODE_NOT_PROMOTED,
    'type' => 'article',
  ]);
  $this
    ->assertFalse($article_node
    ->isPromoted(), 'Node is not promoted before update.');
  $edit['entity_ids[0][target_id]'] = "{$article_node->label()} ({$article_node->id()})";
  $this
    ->drupalPostForm(NULL, $edit, 'Save');
  $this
    ->assertSession()
    ->pageTextNotContains('cannot be referenced.');
  $this
    ->assertTextPattern('/Created the .* Scheduled update/');
  $this
    ->loginLastUser();
  $this
    ->runUpdatesUI();

  // Make sure expect update types were run.
  $this
    ->assertSession()
    ->pageTextContains('Updater New bar type complete. Results: 1 update(s) were performed.');
  $this
    ->assertSession()
    ->pageTextContains('Updater New foo type complete. Results: No updates were performed.');
  $this
    ->checkEntityValue('node', $article_node, 'promote', 1);
}