You are here

public function LanguageNegotiationTest::testTransformWithWeights in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/language/tests/src/Unit/process/LanguageNegotiationTest.php \Drupal\Tests\language\Unit\process\LanguageNegotiationTest::testTransformWithWeights()
  2. 9 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);
}