Pull merge.
[yaffs-website] / web / core / modules / block / tests / src / Functional / Update / BlockRemoveDisabledRegionUpdateTest.php
1 <?php
2
3 namespace Drupal\Tests\block\Functional\Update;
4
5 use Drupal\FunctionalTests\Update\UpdatePathTestBase;
6
7 /**
8  * Tests the upgrade path for removal of disabled region.
9  *
10  * @see https://www.drupal.org/node/2513534
11  *
12  * @group Update
13  * @group legacy
14  */
15 class BlockRemoveDisabledRegionUpdateTest extends UpdatePathTestBase {
16
17   /**
18    * {@inheritdoc}
19    */
20   protected static $modules = ['block_test', 'language'];
21
22   /**
23    * {@inheritdoc}
24    */
25   protected function setDatabaseDumpFiles() {
26     $this->databaseDumpFiles = [
27       __DIR__ . '/../../../../../system/tests/fixtures/update/drupal-8.bare.standard.php.gz',
28       __DIR__ . '/../../../../../system/tests/fixtures/update/drupal-8.update-test-block-disabled-2513534.php',
29     ];
30   }
31
32   /**
33    * Tests that block context mapping is updated properly.
34    */
35   public function testUpdateHookN() {
36     $this->runUpdates();
37
38     // Disable maintenance mode.
39     \Drupal::state()->set('system.maintenance_mode', FALSE);
40
41     // We finished updating so we can login the user now.
42     $this->drupalLogin($this->rootUser);
43
44     // Verify that a disabled block is in the default region.
45     $this->drupalGet('admin/structure/block');
46     $element = $this->xpath("//tr[contains(@data-drupal-selector, :block) and contains(@class, :status)]//select/option[@selected and @value=:region]",
47       [':block' => 'edit-blocks-pagetitle-1', ':status' => 'block-disabled', ':region' => 'header']);
48     $this->assertTrue(!empty($element));
49
50     // Verify that an enabled block is now disabled and in the default region.
51     $this->drupalGet('admin/structure/block');
52     $element = $this->xpath("//tr[contains(@data-drupal-selector, :block) and contains(@class, :status)]//select/option[@selected and @value=:region]",
53       [':block' => 'edit-blocks-pagetitle-2', ':status' => 'block-disabled', ':region' => 'header']);
54     $this->assertTrue(!empty($element));
55
56   }
57
58 }