public function UpdateContribTest::testUpdateContribOrder in Drupal 9
Same name and namespace in other branches
- 8 core/modules/update/tests/src/Functional/UpdateContribTest.php \Drupal\Tests\update\Functional\UpdateContribTest::testUpdateContribOrder()
Tests that contrib projects are ordered by project name.
If a project contains multiple modules, we want to make sure that the available updates report is sorted by the parent project names, not by the names of the modules included in each project. In this test case, we have two contrib projects, "BBB Update test" and "CCC Update test". However, we have a module called "aaa_update_test" that's part of the "CCC Update test" project. We need to make sure that we see the "BBB" project before the "CCC" project, even though "CCC" includes a module that's processed first if you sort alphabetically by module name (which is the order we see things inside \Drupal\Core\Extension\ExtensionList::getList() for example).
File
- core/
modules/ update/ tests/ src/ Functional/ UpdateContribTest.php, line 150
Class
- UpdateContribTest
- Tests how the Update Manager module handles contributed modules and themes in a series of functional tests using mock XML data.
Namespace
Drupal\Tests\update\FunctionalCode
public function testUpdateContribOrder() {
// We want core to be version 8.0.0.
$system_info = [
'#all' => [
'version' => '8.0.0',
],
// All the rest should be visible as contrib modules at version 8.x-1.0.
// aaa_update_test needs to be part of the "CCC Update test" project,
// which would throw off the report if we weren't properly sorting by
// the project names.
'aaa_update_test' => [
'project' => 'ccc_update_test',
'version' => '8.x-1.0',
'hidden' => FALSE,
],
// This should be its own project, and listed first on the report.
'bbb_update_test' => [
'project' => 'bbb_update_test',
'version' => '8.x-1.0',
'hidden' => FALSE,
],
// This will contain both aaa_update_test and ccc_update_test, and
// should come after the bbb_update_test project.
'ccc_update_test' => [
'project' => 'ccc_update_test',
'version' => '8.x-1.0',
'hidden' => FALSE,
],
];
$this
->config('update_test.settings')
->set('system_info', $system_info)
->save();
$this
->refreshUpdateStatus([
'drupal' => '0.0',
'#all' => '1_0',
]);
$this
->standardTests();
// We're expecting the report to say all projects are up to date.
$this
->assertSession()
->pageTextContains('Up to date');
$this
->assertSession()
->pageTextNotContains('Update available');
// We want to see all 3 module names listed, since they'll show up either
// as project names or as modules under the "Includes" listing.
$this
->assertSession()
->pageTextContains('AAA Update test');
$this
->assertSession()
->pageTextContains('BBB Update test');
$this
->assertSession()
->pageTextContains('CCC Update test');
// We want aaa_update_test included in the ccc_update_test project, not as
// its own project on the report.
$this
->assertSession()
->linkNotExists('AAA Update test');
$this
->assertSession()
->linkByHrefNotExists('http://example.com/project/aaa_update_test');
// The other two should be listed as projects.
$this
->assertSession()
->linkExists('BBB Update test');
$this
->assertSession()
->linkByHrefExists('http://example.com/project/bbb_update_test');
$this
->assertSession()
->linkExists('CCC Update test');
$this
->assertSession()
->linkByHrefExists('http://example.com/project/ccc_update_test');
// We want to make sure we see the BBB project before the CCC project.
// Instead of just searching for 'BBB Update test' or something, we want
// to use the full markup that starts the project entry itself, so that
// we're really testing that the project listings are in the right order.
$bbb_project_link = '<div class="project-update__title"><a href="http://example.com/project/bbb_update_test">BBB Update test</a>';
$ccc_project_link = '<div class="project-update__title"><a href="http://example.com/project/ccc_update_test">CCC Update test</a>';
// Verify that the 'BBB Update test' project is listed before the
// 'CCC Update test' project.
$this
->assertLessThan(strpos($this
->getSession()
->getPage()
->getContent(), $ccc_project_link), strpos($this
->getSession()
->getPage()
->getContent(), $bbb_project_link));
}