You are here

function UpdateCoreTest::testFetchTasks in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/update/src/Tests/UpdateCoreTest.php \Drupal\update\Tests\UpdateCoreTest::testFetchTasks()

Tests that exactly one fetch task per project is created and not more.

File

core/modules/update/src/Tests/UpdateCoreTest.php, line 306
Contains \Drupal\update\Tests\UpdateCoreTest.

Class

UpdateCoreTest
Tests the Update Manager module through a series of functional tests using mock XML data.

Namespace

Drupal\update\Tests

Code

function testFetchTasks() {
  $projecta = array(
    'name' => 'aaa_update_test',
  );
  $projectb = array(
    'name' => 'bbb_update_test',
  );
  $queue = \Drupal::queue('update_fetch_tasks');
  $this
    ->assertEqual($queue
    ->numberOfItems(), 0, 'Queue is empty');
  update_create_fetch_task($projecta);
  $this
    ->assertEqual($queue
    ->numberOfItems(), 1, 'Queue contains one item');
  update_create_fetch_task($projectb);
  $this
    ->assertEqual($queue
    ->numberOfItems(), 2, 'Queue contains two items');

  // Try to add project a again.
  update_create_fetch_task($projecta);
  $this
    ->assertEqual($queue
    ->numberOfItems(), 2, 'Queue still contains two items');

  // Clear storage and try again.
  update_storage_clear();
  update_create_fetch_task($projecta);
  $this
    ->assertEqual($queue
    ->numberOfItems(), 2, 'Queue contains two items');
}