Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / web / core / modules / system / tests / src / Functional / Update / UpdatePostUpdateFailingTest.php
1 <?php
2
3 namespace Drupal\Tests\system\Functional\Update;
4
5 use Drupal\FunctionalTests\Update\UpdatePathTestBase;
6
7 /**
8  * Tests hook_post_update() when there are failing update hooks.
9  *
10  * @group Update
11  */
12 class UpdatePostUpdateFailingTest extends UpdatePathTestBase {
13
14   /**
15    * {@inheritdoc}
16    */
17   protected function setDatabaseDumpFiles() {
18     $this->databaseDumpFiles = [
19       __DIR__ . '/../../../../tests/fixtures/update/drupal-8.bare.standard.php.gz',
20       __DIR__ . '/../../../../tests/fixtures/update/drupal-8.update-test-postupdate-failing-enabled.php',
21     ];
22   }
23
24   /**
25    * Tests hook_post_update_NAME().
26    */
27   public function testPostUpdate() {
28     // There are expected to be failed updates.
29     $this->checkFailedUpdates = FALSE;
30
31     $this->runUpdates();
32
33     // There should be no post update hooks registered as being run.
34     $this->assertIdentical([], \Drupal::state()->get('post_update_test_execution', []));
35
36     $key_value = \Drupal::keyValue('update__post_update');
37     $this->assertEqual([], $key_value->get('existing_updates', []));
38   }
39
40   /**
41    * {@inheritdoc}
42    */
43   protected function doSelectionTest() {
44     // First update, should not be run since this module's update hooks fail.
45     $this->assertRaw('8001 -   This update will fail.');
46     $this->assertRaw('8002 -   A further update.');
47     $this->assertEscaped("First update, should not be run since this module's update hooks fail.");
48   }
49
50 }