e11999a46c2312d0a3f5c63cdeec367098398f26
[yaffs-website] / web / core / modules / system / tests / src / Functional / Update / DependencyMissingTest.php
1 <?php
2
3 namespace Drupal\Tests\system\Functional\Update;
4
5 use Drupal\Tests\BrowserTestBase;
6
7 /**
8  * Tests that missing update dependencies are correctly flagged.
9  *
10  * @group Update
11  */
12 class DependencyMissingTest extends BrowserTestBase {
13
14   /**
15    * Modules to enable.
16    *
17    * @var array
18    */
19   public static $modules = ['update_test_0', 'update_test_2'];
20
21   protected function setUp() {
22     // Only install update_test_2.module, even though its updates have a
23     // dependency on update_test_3.module.
24     parent::setUp();
25     require_once $this->root . '/core/includes/update.inc';
26   }
27
28   public function testMissingUpdate() {
29     $starting_updates = [
30       'update_test_2' => 8001,
31     ];
32     $update_graph = update_resolve_dependencies($starting_updates);
33     $this->assertTrue($update_graph['update_test_2_update_8001']['allowed'], "The module's first update function is allowed to run, since it does not have any missing dependencies.");
34     $this->assertFalse($update_graph['update_test_2_update_8002']['allowed'], "The module's second update function is not allowed to run, since it has a direct dependency on a missing update.");
35     $this->assertFalse($update_graph['update_test_2_update_8003']['allowed'], "The module's third update function is not allowed to run, since it has an indirect dependency on a missing update.");
36   }
37
38 }