3 namespace Drupal\Tests\system\Functional\Update;
5 use Drupal\Tests\BrowserTestBase;
8 * Tests that update functions are run in the proper order.
12 class DependencyOrderingTest extends BrowserTestBase {
19 public static $modules = ['update_test_0', 'update_test_1', 'update_test_2', 'update_test_3'];
21 protected function setUp() {
23 require_once $this->root . '/core/includes/update.inc';
27 * Test that updates within a single module run in the correct order.
29 public function testUpdateOrderingSingleModule() {
31 'update_test_1' => 8001,
34 'update_test_1_update_8001',
35 'update_test_1_update_8002',
36 'update_test_1_update_8003',
38 $actual_updates = array_keys(update_resolve_dependencies($starting_updates));
39 $this->assertEqual($expected_updates, $actual_updates, 'Updates within a single module run in the correct order.');
43 * Test that dependencies between modules are resolved correctly.
45 public function testUpdateOrderingModuleInterdependency() {
47 'update_test_2' => 8001,
48 'update_test_3' => 8001,
50 $update_order = array_keys(update_resolve_dependencies($starting_updates));
51 // Make sure that each dependency is satisfied.
52 $first_dependency_satisfied = array_search('update_test_2_update_8001', $update_order) < array_search('update_test_3_update_8001', $update_order);
53 $this->assertTrue($first_dependency_satisfied, 'The dependency of the second module on the first module is respected by the update function order.');
54 $second_dependency_satisfied = array_search('update_test_3_update_8001', $update_order) < array_search('update_test_2_update_8002', $update_order);
55 $this->assertTrue($second_dependency_satisfied, 'The dependency of the first module on the second module is respected by the update function order.');