MigrateLinkDomainSettingFromRestToHalUpdateTest.php 1.67 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
<?php

namespace Drupal\Tests\hal\Functional\Update;

use Drupal\system\Tests\Update\UpdatePathTestBase;

/**
 * 'link_domain' is migrated from 'rest.settings' to 'hal.settings'.
 *
 * @see https://www.drupal.org/node/2758897
 *
 * @group hal
 */
class MigrateLinkDomainSettingFromRestToHalUpdateTest extends UpdatePathTestBase {

  /**
   * {@inheritdoc}
   */
  public function setDatabaseDumpFiles() {
    $this->databaseDumpFiles = [
      __DIR__ . '/../../../../../system/tests/fixtures/update/drupal-8.bare.standard.php.gz',
      __DIR__ . '/../../../fixtures/update/drupal-8.hal-hal_update_8301.php',
      __DIR__ . '/../../../fixtures/update/drupal-8.rest-hal_update_8301.php',
    ];
  }

  /**
   * Tests hal_update_8301().
   */
  public function testLinkDomainMigratedFromRestSettingsToHalSettings() {
    // Make sure we have the expected values before the update.
    $hal_settings = $this->config('hal.settings');
    $this->assertIdentical([], $hal_settings->getRawData());
    $rest_settings = $this->config('rest.settings');
    $this->assertTrue(array_key_exists('link_domain', $rest_settings->getRawData()));
    $this->assertIdentical('http://example.com', $rest_settings->getRawData()['link_domain']);

    $this->runUpdates();

    // Make sure we have the expected values after the update.
    $hal_settings = \Drupal::configFactory()->get('hal.settings');
    $this->assertTrue(array_key_exists('link_domain', $hal_settings->getRawData()));
    $this->assertIdentical('http://example.com', $hal_settings->getRawData()['link_domain']);
    $rest_settings = $this->config('rest.settings');
    $this->assertFalse(array_key_exists('link_domain', $rest_settings->getRawData()));
  }

}