You are here

public function MigrateVariablesTest::testMigrationWithUnsetVariables in Style Switcher 3.0.x

Same name and namespace in other branches
  1. 8.2 tests/src/Kernel/Migrate/d7/MigrateVariablesTest.php \Drupal\Tests\styleswitcher\Kernel\Migrate\d7\MigrateVariablesTest::testMigrationWithUnsetVariables()

Tests migration with unset variables.

File

tests/src/Kernel/Migrate/d7/MigrateVariablesTest.php, line 61

Class

MigrateVariablesTest
Tests migration of Style Switcher variables to configuration objects.

Namespace

Drupal\Tests\styleswitcher\Kernel\Migrate\d7

Code

public function testMigrationWithUnsetVariables() {
  $variables = [
    'styleswitcher_enable_overlay',
    'styleswitcher_7206_theme_default',
    'styleswitcher_styles_settings',
  ];
  $this->sourceDatabase
    ->delete('variable')
    ->condition('name', $variables, 'IN')
    ->execute();
  $this
    ->startCollectingMessages();
  $this
    ->executeMigrations([
    'd7_styleswitcher_settings',
    'd7_styleswitcher_styles_settings',
  ]);

  // Make sure there's no migration exceptions.
  $migrate_id_map = $this->migration
    ->getIdMap();
  $messages = floatval(\Drupal::VERSION) >= 8.800000000000001 ? $migrate_id_map
    ->getMessages() : $migrate_id_map
    ->getMessageIterator();
  $this
    ->assertEmpty($messages
    ->fetchAll());

  // Make sure default settings are as they were default in D7.
  $settings = $this
    ->config('styleswitcher.settings');
  $this
    ->assertTrue($settings
    ->get('enable_overlay'));
  $this
    ->assertNull($settings
    ->get('7206_theme_default'));
  $this
    ->assertSame([], $this
    ->config('styleswitcher.styles_settings')
    ->get('settings'));
}