BlockRemoveDisabledRegionUpdateTest.php 1.9 KB

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