function UpdateManagerUpdateTest::testUninstalledUpdatesTable
Same name in other branches
- 11.x core/modules/update/tests/src/Functional/UpdateManagerUpdateTest.php \Drupal\Tests\update\Functional\UpdateManagerUpdateTest::testUninstalledUpdatesTable()
Tests the Update form with an uninstalled module in the system.
File
-
core/
modules/ update/ tests/ src/ Functional/ UpdateManagerUpdateTest.php, line 232
Class
- UpdateManagerUpdateTest
- Tests the Update Manager module's 'Update' form and functionality.
Namespace
Drupal\Tests\update\FunctionalCode
public function testUninstalledUpdatesTable() : void {
$assert_session = $this->assertSession();
$compatible_table_locator = '[data-drupal-selector="edit-projects"]';
$uninstalled_table_locator = '[data-drupal-selector="edit-uninstalled-projects"]';
$fixtures = [
'drupal' => '8.1.1',
'aaa_update_test' => '8.x-1.2',
// Use a fixture with only a 8.x-1.0 release so BBB is up to date.
'bbb_update_test' => '1_0',
// CCC is not installed and is missing an update, 8.x-1.1.
'ccc_update_test' => '1_1',
];
$this->refreshUpdateStatus($fixtures);
$this->drupalGet('admin/reports/updates/update');
// Confirm there is no table for uninstalled extensions.
$assert_session->pageTextNotContains('CCC Update test');
$assert_session->responseNotContains('<h2>Uninstalled</h2>');
// Confirm the table for installed modules exists without a header.
$assert_session->responseNotContains('<h2>Installed</h2>');
$assert_session->elementNotExists('css', $uninstalled_table_locator);
$assert_session->elementsCount('css', "{$compatible_table_locator} tbody tr", 1);
$compatible_headers = [
// First column has no header, it's the select-all checkbox.
'th:nth-of-type(2)' => 'Name',
'th:nth-of-type(3)' => 'Site version',
'th:nth-of-type(4)' => 'Recommended version',
];
$this->checkTableHeaders($compatible_table_locator, $compatible_headers);
$installed_row = "{$compatible_table_locator} tbody tr";
$assert_session->elementsCount('css', $installed_row, 1);
$assert_session->elementTextContains('css', "{$compatible_table_locator} td:nth-of-type(2)", "AAA Update test");
$assert_session->elementTextContains('css', "{$compatible_table_locator} td:nth-of-type(3)", '8.x-1.0');
$assert_session->elementTextContains('css', "{$compatible_table_locator} td:nth-of-type(4)", '8.x-1.2');
// Change the setting so we check for uninstalled modules, too.
$this->config('update.settings')
->set('check.disabled_extensions', TRUE)
->save();
// Reload the page so the new setting goes into effect.
$this->drupalGet('admin/reports/updates/update');
// Confirm the table for installed modules exists with a header.
$assert_session->responseContains('<h2>Installed</h2>');
$assert_session->elementsCount('css', "{$compatible_table_locator} tbody tr", 1);
$this->checkTableHeaders($compatible_table_locator, $compatible_headers);
// Confirm the table for uninstalled extensions exists.
$assert_session->responseContains('<h2>Uninstalled</h2>');
$uninstalled_headers = [
// First column has no header, it's the select-all checkbox.
'th:nth-of-type(2)' => 'Name',
'th:nth-of-type(3)' => 'Site version',
'th:nth-of-type(4)' => 'Recommended version',
];
$this->checkTableHeaders($uninstalled_table_locator, $uninstalled_headers);
$uninstalled_row = "{$uninstalled_table_locator} tbody tr";
$assert_session->elementsCount('css', $uninstalled_row, 1);
$assert_session->elementTextContains('css', "{$uninstalled_row} td:nth-of-type(2)", "CCC Update test");
$assert_session->elementTextContains('css', "{$uninstalled_row} td:nth-of-type(3)", '8.x-1.0');
$assert_session->elementTextContains('css', "{$uninstalled_row} td:nth-of-type(4)", '8.x-1.1');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.