3 namespace Drupal\Tests\language\Unit\process;
5 use Drupal\language\Plugin\migrate\process\LanguageDomains;
6 use Drupal\Tests\migrate\Unit\process\MigrateProcessTestCase;
9 * @coversDefaultClass \Drupal\language\Plugin\migrate\process\LanguageDomains
12 class LanguageDomainsTest extends MigrateProcessTestCase {
17 protected $backupGlobalsBlacklist = ['base_url'];
22 protected function setUp() {
27 $this->plugin = new LanguageDomains($configuration, 'map', []);
30 // The language_domains plugin calls getSourceProperty() to check if domain
31 // negotiation is used. If it is the values will be processed so we need it
32 // to return TRUE to be able to test the process.
33 $this->row->expects($this->once())
34 ->method('getSourceProperty')
35 ->will($this->returnValue(TRUE));
37 // The language_domains plugin use $base_url to fill empty domains.
39 $base_url = 'http://example.com';
45 public function testTransform() {
47 ['language' => 'en', 'domain' => ''],
48 ['language' => 'fr', 'domain' => 'fr.example.com'],
49 ['language' => 'es', 'domain' => 'http://es.example.com'],
50 ['language' => 'hu', 'domain' => 'https://hu.example.com'],
53 'en' => 'example.com',
54 'fr' => 'fr.example.com',
55 'es' => 'es.example.com',
56 'hu' => 'hu.example.com',
58 $value = $this->plugin->transform($source, $this->migrateExecutable, $this->row, 'destinationproperty');
59 $this->assertSame($value, $expected);