e710a4ecaf756cd1d73fdcb7b9a86270816b85d9
[yaffs-website] / web / core / modules / system / src / Tests / Update / UpdatePathWithBrokenRoutingTest.php
1 <?php
2
3 namespace Drupal\system\Tests\Update;
4
5 /**
6  * Tests the update path with a broken router.
7  *
8  * @group Update
9  */
10 class UpdatePathWithBrokenRoutingTest extends UpdatePathTestBase {
11
12   /**
13    * {@inheritdoc}
14    */
15   protected function setDatabaseDumpFiles() {
16     $this->databaseDumpFiles = [
17       __DIR__ . '/../../../tests/fixtures/update/drupal-8.bare.standard.php.gz',
18       __DIR__ . '/../../../tests/fixtures/update/drupal-8.broken_routing.php',
19     ];
20   }
21
22   /**
23    * Tests running update.php with some form of broken routing.
24    */
25   public function testWithBrokenRouting() {
26     // Simulate a broken router, and make sure the front page is
27     // inaccessible.
28     \Drupal::state()->set('update_script_test_broken_inbound', TRUE);
29     \Drupal::service('cache_tags.invalidator')->invalidateTags(['route_match', 'rendered']);
30     $this->drupalGet('<front>');
31     $this->assertResponse(500);
32
33     // The exceptions are expected. Do not interpret them as a test failure.
34     // Not using File API; a potential error must trigger a PHP warning.
35     unlink(\Drupal::root() . '/' . $this->siteDirectory . '/error.log');
36     foreach ($this->assertions as $key => $assertion) {
37       if (strpos($assertion['message'], 'core/modules/system/tests/modules/update_script_test/src/PathProcessor/BrokenInboundPathProcessor.php') !== FALSE) {
38         unset($this->assertions[$key]);
39         $this->deleteAssert($assertion['message_id']);
40       }
41     }
42
43     $this->runUpdates();
44
45     // Remove the simulation of the broken router, and make sure we can get to
46     // the front page again.
47     \Drupal::state()->set('update_script_test_broken_inbound', FALSE);
48     $this->drupalGet('<front>');
49     $this->assertResponse(200);
50   }
51
52 }