function MigrateLanguageNegotiationSettingsTest::testLanguageNegotiationWithPrefix

Same name in other branches
  1. 9 core/modules/language/tests/src/Kernel/Migrate/d7/MigrateLanguageNegotiationSettingsTest.php \Drupal\Tests\language\Kernel\Migrate\d7\MigrateLanguageNegotiationSettingsTest::testLanguageNegotiationWithPrefix()
  2. 10 core/modules/language/tests/src/Kernel/Migrate/d7/MigrateLanguageNegotiationSettingsTest.php \Drupal\Tests\language\Kernel\Migrate\d7\MigrateLanguageNegotiationSettingsTest::testLanguageNegotiationWithPrefix()
  3. 11.x core/modules/language/tests/src/Kernel/Migrate/d7/MigrateLanguageNegotiationSettingsTest.php \Drupal\Tests\language\Kernel\Migrate\d7\MigrateLanguageNegotiationSettingsTest::testLanguageNegotiationWithPrefix()

Tests the migration with prefix negotiation.

File

core/modules/language/tests/src/Kernel/Migrate/d7/MigrateLanguageNegotiationSettingsTest.php, line 55

Class

MigrateLanguageNegotiationSettingsTest
Tests the migration of language negotiation.

Namespace

Drupal\Tests\language\Kernel\Migrate\d7

Code

public function testLanguageNegotiationWithPrefix() {
    $this->sourceDatabase
        ->update('languages')
        ->fields([
        'domain' => '',
    ])
        ->execute();
    $this->executeMigrations([
        'language',
        'd7_language_negotiation_settings',
        'language_prefixes_and_domains',
    ]);
    $config = $this->config('language.negotiation');
    $this->assertSame('language', $config->get('session.parameter'));
    $this->assertSame(LanguageNegotiationUrl::CONFIG_PATH_PREFIX, $config->get('url.source'));
    $this->assertSame('site_default', $config->get('selected_langcode'));
    $expected_prefixes = [
        'en' => '',
        'fr' => 'fr',
        'is' => 'is',
    ];
    $this->assertSame($expected_prefixes, $config->get('url.prefixes'));
    // If prefix negotiation is used, make sure that no domains are migrated.
    // Otherwise there will be validation errors when trying to save URL
    // language detection configuration from the UI.
    $expected_domains = [
        'en' => '',
        'fr' => '',
        'is' => '',
    ];
    $this->assertSame($expected_domains, $config->get('url.domains'));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.