function UpdateSemverCoreTest::testFetchTasks

Same name in other branches
  1. 9 core/modules/update/tests/src/Functional/UpdateSemverCoreTest.php \Drupal\Tests\update\Functional\UpdateSemverCoreTest::testFetchTasks()
  2. 10 core/modules/update/tests/src/Functional/UpdateSemverCoreTest.php \Drupal\Tests\update\Functional\UpdateSemverCoreTest::testFetchTasks()

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

File

core/modules/update/tests/src/Functional/UpdateSemverCoreTest.php, line 54

Class

UpdateSemverCoreTest
Tests edge cases of the Available Updates report UI.

Namespace

Drupal\Tests\update\Functional

Code

public function testFetchTasks() : void {
    $project_a = [
        'name' => 'aaa_update_test',
    ];
    $project_b = [
        'name' => 'bbb_update_test',
    ];
    $queue = \Drupal::queue('update_fetch_tasks');
    $this->assertEquals(0, $queue->numberOfItems(), 'Queue is empty');
    update_create_fetch_task($project_a);
    $this->assertEquals(1, $queue->numberOfItems(), 'Queue contains one item');
    update_create_fetch_task($project_b);
    $this->assertEquals(2, $queue->numberOfItems(), 'Queue contains two items');
    // Try to add a project again.
    update_create_fetch_task($project_a);
    $this->assertEquals(2, $queue->numberOfItems(), 'Queue still contains two items');
    // Clear storage and try again.
    update_storage_clear();
    update_create_fetch_task($project_a);
    $this->assertEquals(2, $queue->numberOfItems(), 'Queue contains two items');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.