ef22f0e1b34d2d8e8d796c0051c3a1ac9b817b87
[yaffs-website] / web / core / modules / system / src / Tests / Update / DependencyHookInvocationTest.php
1 <?php
2
3 namespace Drupal\system\Tests\Update;
4
5 use Drupal\simpletest\WebTestBase;
6
7 /**
8  * Tests that the hook invocation for determining update dependencies works
9  * correctly.
10  *
11  * @group Update
12  */
13 class DependencyHookInvocationTest extends WebTestBase {
14
15   /**
16    * Modules to enable.
17    *
18    * @var array
19    */
20   public static $modules = ['update_test_0', 'update_test_1', 'update_test_2'];
21
22   protected function setUp() {
23     parent::setUp();
24     require_once \Drupal::root() . '/core/includes/update.inc';
25   }
26
27   /**
28    * Test the structure of the array returned by hook_update_dependencies().
29    */
30   public function testHookUpdateDependencies() {
31     $update_dependencies = update_retrieve_dependencies();
32     $this->assertTrue($update_dependencies['update_test_0'][8001]['update_test_1'] == 8001, 'An update function that has a dependency on two separate modules has the first dependency recorded correctly.');
33     $this->assertTrue($update_dependencies['update_test_0'][8001]['update_test_2'] == 8002, 'An update function that has a dependency on two separate modules has the second dependency recorded correctly.');
34     $this->assertTrue($update_dependencies['update_test_0'][8002]['update_test_1'] == 8003, 'An update function that depends on more than one update from the same module only has the dependency on the higher-numbered update function recorded.');
35   }
36
37 }