View source
<?php
namespace Drupal\Tests\language\Unit\process;
use Drupal\language\Plugin\migrate\process\LanguageDomains;
use Drupal\Tests\migrate\Unit\process\MigrateProcessTestCase;
class LanguageDomainsTest extends MigrateProcessTestCase {
protected $backupGlobalsBlacklist = [
'base_url',
];
protected function setUp() {
$configuration = [
'key' => 'language',
'value' => 'domain',
];
$this->plugin = new LanguageDomains($configuration, 'map', []);
parent::setUp();
$this->row
->expects($this
->once())
->method('getSourceProperty')
->will($this
->returnValue(TRUE));
global $base_url;
$base_url = 'http://example.com';
}
public function testTransform() {
$source = [
[
'language' => 'en',
'domain' => '',
],
[
'language' => 'fr',
'domain' => 'fr.example.com',
],
[
'language' => 'es',
'domain' => 'http://es.example.com',
],
[
'language' => 'hu',
'domain' => 'https://hu.example.com',
],
];
$expected = [
'en' => 'example.com',
'fr' => 'fr.example.com',
'es' => 'es.example.com',
'hu' => 'hu.example.com',
];
$value = $this->plugin
->transform($source, $this->migrateExecutable, $this->row, 'destination_property');
$this
->assertSame($value, $expected);
}
}