function LanguageNegotiationTest::testTransformWithWeights

Same name in other branches
  1. 9 core/modules/language/tests/src/Unit/process/LanguageNegotiationTest.php \Drupal\Tests\language\Unit\process\LanguageNegotiationTest::testTransformWithWeights()
  2. 10 core/modules/language/tests/src/Unit/process/LanguageNegotiationTest.php \Drupal\Tests\language\Unit\process\LanguageNegotiationTest::testTransformWithWeights()
  3. 11.x core/modules/language/tests/src/Unit/process/LanguageNegotiationTest.php \Drupal\Tests\language\Unit\process\LanguageNegotiationTest::testTransformWithWeights()

Tests successful transformation without weights.

File

core/modules/language/tests/src/Unit/process/LanguageNegotiationTest.php, line 26

Class

LanguageNegotiationTest
@coversDefaultClass \Drupal\language\Plugin\migrate\process\LanguageNegotiation @group language

Namespace

Drupal\Tests\language\Unit\process

Code

public function testTransformWithWeights() {
    $source = [
        [
            'locale-url' => [],
            'language-default' => [],
        ],
        [
            'locale-url' => -10,
            'locale-session' => -9,
            'locale-user' => -8,
            'locale-browser' => -7,
            'language-default' => -6,
        ],
    ];
    $expected = [
        'enabled' => [
            'language-url' => -10,
            'language-selected' => -6,
        ],
        'method_weights' => [
            'language-url' => -10,
            'language-session' => -9,
            'language-user' => -8,
            'language-browser' => -7,
            'language-selected' => -6,
        ],
    ];
    $value = $this->plugin
        ->transform($source, $this->migrateExecutable, $this->row, 'destination_property');
    $this->assertSame($value, $expected);
}

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