public function UpdateSemverCoreTest::testFetchTasks in Drupal 10
Same name and namespace in other branches
- 9 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 448
Class
- UpdateSemverCoreTest
- Tests the Update Manager module through a series of functional tests using mock XML data.
Namespace
Drupal\Tests\update\FunctionalCode
public function testFetchTasks() {
$projecta = [
'name' => 'aaa_update_test',
];
$projectb = [
'name' => 'bbb_update_test',
];
$queue = \Drupal::queue('update_fetch_tasks');
$this
->assertEquals(0, $queue
->numberOfItems(), 'Queue is empty');
update_create_fetch_task($projecta);
$this
->assertEquals(1, $queue
->numberOfItems(), 'Queue contains one item');
update_create_fetch_task($projectb);
$this
->assertEquals(2, $queue
->numberOfItems(), 'Queue contains two items');
// Try to add a project again.
update_create_fetch_task($projecta);
$this
->assertEquals(2, $queue
->numberOfItems(), 'Queue still contains two items');
// Clear storage and try again.
update_storage_clear();
update_create_fetch_task($projecta);
$this
->assertEquals(2, $queue
->numberOfItems(), 'Queue contains two items');
}