class DependencyOrderingTest
Same name and namespace in other branches
- 11.x core/modules/system/tests/src/Functional/UpdateSystem/DependencyOrderingTest.php \Drupal\Tests\system\Functional\UpdateSystem\DependencyOrderingTest
- 10 core/modules/system/tests/src/Functional/UpdateSystem/DependencyOrderingTest.php \Drupal\Tests\system\Functional\UpdateSystem\DependencyOrderingTest
- 8.9.x core/modules/system/tests/src/Functional/UpdateSystem/DependencyOrderingTest.php \Drupal\Tests\system\Functional\UpdateSystem\DependencyOrderingTest
Tests that update functions are run in the proper order.
@group Update
Hierarchy
- class \Drupal\Tests\BrowserTestBase uses \Drupal\Core\Test\FunctionalTestSetupTrait, \Drupal\Tests\UiHelperTrait, \Drupal\Core\Test\TestSetupTrait, \Drupal\Tests\block\Traits\BlockCreationTrait, \Drupal\FunctionalTests\AssertLegacyTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\node\Traits\NodeCreationTrait, \Drupal\Tests\node\Traits\ContentTypeCreationTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\user\Traits\UserCreationTrait, \Drupal\Tests\XdebugRequestTrait, \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait, \Drupal\Tests\ExtensionListTestTrait implements \PHPUnit\Framework\TestCase
- class \Drupal\Tests\system\Functional\UpdateSystem\DependencyOrderingTest implements \Drupal\Tests\BrowserTestBase
Expanded class hierarchy of DependencyOrderingTest
File
-
core/
modules/ system/ tests/ src/ Functional/ UpdateSystem/ DependencyOrderingTest.php, line 12
Namespace
Drupal\Tests\system\Functional\UpdateSystemView source
class DependencyOrderingTest extends BrowserTestBase {
/**
* Modules to enable.
*
* @var array
*/
protected static $modules = [
'update_test_0',
'update_test_1',
'update_test_2',
'update_test_3',
];
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* {@inheritdoc}
*/
protected function setUp() : void {
parent::setUp();
require_once $this->root . '/core/includes/update.inc';
}
/**
* Tests that updates within a single module run in the correct order.
*/
public function testUpdateOrderingSingleModule() {
$starting_updates = [
'update_test_1' => 8001,
];
$expected_updates = [
'update_test_1_update_8001',
'update_test_1_update_8002',
'update_test_1_update_8003',
];
$actual_updates = array_keys(update_resolve_dependencies($starting_updates));
$this->assertEquals($expected_updates, $actual_updates, 'Updates within a single module run in the correct order.');
}
/**
* Tests that dependencies between modules are resolved correctly.
*/
public function testUpdateOrderingModuleInterdependency() {
$starting_updates = [
'update_test_2' => 8001,
'update_test_3' => 8001,
];
$update_order = array_keys(update_resolve_dependencies($starting_updates));
// Make sure that each dependency is satisfied.
$first_dependency_satisfied = array_search('update_test_2_update_8001', $update_order) < array_search('update_test_3_update_8001', $update_order);
$this->assertTrue($first_dependency_satisfied, 'The dependency of the second module on the first module is respected by the update function order.');
$second_dependency_satisfied = array_search('update_test_3_update_8001', $update_order) < array_search('update_test_2_update_8002', $update_order);
$this->assertTrue($second_dependency_satisfied, 'The dependency of the first module on the second module is respected by the update function order.');
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.