1 update.test UpdateCoreTestCase::testFetchTasks()

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

File

core/modules/update/tests/update.test, line 235
This file contains tests for the Update Manager module.

Class

UpdateCoreTestCase

Code

function testFetchTasks() {
  $projecta = array(
    'name' => 'aaa_update_test',
  );
  $projectb = array(
    'name' => 'bbb_update_test',
  );
  $queue = BackdropQueue::get('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 cache and try again.
  _update_cache_clear();
  backdrop_static_reset('_update_create_fetch_task');
  update_create_fetch_task($projecta);
  $this->assertEqual($queue->numberOfItems(), 2, 'Queue contains two items');
}