You are here

public function Update8006Test::testUpdate in Lightning Core 8

Same name and namespace in other branches
  1. 8.5 tests/src/Functional/Update/Update8006Test.php \Drupal\Tests\lightning_core\Functional\Update\Update8006Test::testUpdate()
  2. 8.2 tests/src/Functional/Update/Update8006Test.php \Drupal\Tests\lightning_core\Functional\Update\Update8006Test::testUpdate()
  3. 8.3 tests/src/Functional/Update/Update8006Test.php \Drupal\Tests\lightning_core\Functional\Update\Update8006Test::testUpdate()
  4. 8.4 tests/src/Functional/Update/Update8006Test.php \Drupal\Tests\lightning_core\Functional\Update\Update8006Test::testUpdate()

File

tests/src/Functional/Update/Update8006Test.php, line 23

Class

Update8006Test
@group lightning @group lightning_core

Namespace

Drupal\Tests\lightning_core\Functional\Update

Code

public function testUpdate() {
  $old_name = 'lightning.versions';
  $new_name = UpdateManager::CONFIG_NAME;

  // When doing a lot of updates, it's possible that lightning_core.versions
  // will exist before update 8007 runs, so we need to simulate that case.
  $this
    ->config($new_name)
    ->set('foo', '5.1.0')
    ->save();

  // Ensure that update 8006 works if lightning.versions exists.
  $this
    ->config($old_name)
    ->set('foo', '5.0.0')
    ->set('bar', '1.0.0')
    ->save();
  $this
    ->runUpdates();

  // Assert that lightning.versions is gone, but its data is preserved.
  $this
    ->assertTrue($this
    ->config($old_name)
    ->isNew());
  $new = $this
    ->config($new_name);
  $this
    ->assertSame('5.1.0', $new
    ->get('foo'));
  $this
    ->assertSame('1.0.0', $new
    ->get('bar'));
}