44d4832dd2caec7a2770d9dc2a5d70f51c005b50
[yaffs-website] / web / core / modules / system / tests / src / Functional / Update / InvalidUpdateHookTest.php
1 <?php
2
3 namespace Drupal\Tests\system\Functional\Update;
4
5 use Drupal\Tests\BrowserTestBase;
6
7 /**
8  * Tests that a module implementing hook_update_8000() causes an error to be
9  * displayed on update.
10  *
11  * @group Update
12  */
13 class InvalidUpdateHookTest extends BrowserTestBase {
14
15   /**
16    * Modules to enable.
17    *
18    * @var array
19    */
20   public static $modules = ['update_test_invalid_hook', 'update_script_test', 'dblog'];
21
22   /**
23    * URL for the upgrade script.
24    *
25    * @var string
26    */
27   private $updateUrl;
28
29   /**
30    * A user account with upgrade permission.
31    *
32    * @var \Drupal\user\UserInterface
33    */
34   private $updateUser;
35
36   protected function setUp() {
37     parent::setUp();
38     require_once \Drupal::root() . '/core/includes/update.inc';
39
40     $this->updateUrl = $GLOBALS['base_url'] . '/update.php';
41     $this->updateUser = $this->drupalCreateUser(['administer software updates']);
42   }
43
44   public function testInvalidUpdateHook() {
45     // Confirm that a module with hook_update_8000() cannot be updated.
46     $this->drupalLogin($this->updateUser);
47     $this->drupalGet($this->updateUrl);
48     $this->clickLink(t('Continue'));
49     $this->assertText(t('Some of the pending updates cannot be applied because their dependencies were not met.'));
50   }
51
52 }