3 namespace Drupal\Tests\language\Unit\process;
5 use Drupal\language\Plugin\migrate\process\LanguageNegotiation;
6 use Drupal\Tests\migrate\Unit\process\MigrateProcessTestCase;
7 use Drupal\migrate\MigrateException;
10 * @coversDefaultClass \Drupal\language\Plugin\migrate\process\LanguageNegotiation
13 class LanguageNegotiationTest extends MigrateProcessTestCase {
18 protected function setUp() {
19 $this->plugin = new LanguageNegotiation([], 'map', []);
24 * Tests successful transformation without weights.
26 public function testTransformWithWeights() {
30 'language-default' => [],
34 'locale-session' => -9,
36 'locale-browser' => -7,
37 'language-default' => -6,
42 'language-url' => -10,
43 'language-selected' => -6,
46 'language-url' => -10,
47 'language-session' => -9,
48 'language-user' => -8,
49 'language-browser' => -7,
50 'language-selected' => -6,
53 $value = $this->plugin->transform($source, $this->migrateExecutable, $this->row, 'destinationproperty');
54 $this->assertSame($value, $expected);
58 * Tests successful transformation without weights.
60 public function testTransformWithoutWeights() {
64 'locale-url-fallback' => [],
70 'language-url-fallback' => 1,
73 $value = $this->plugin->transform($source, $this->migrateExecutable, $this->row, 'destinationproperty');
74 $this->assertSame($value, $expected);
80 public function testStringInput() {
81 $this->plugin = new LanguageNegotiation([], 'map', []);
82 $this->setExpectedException(MigrateException::class, 'The input should be an array');
83 $this->plugin->transform('foo', $this->migrateExecutable, $this->row, 'destinationproperty');