View source
<?php
namespace Drupal\Tests\language\Functional;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\Tests\BrowserTestBase;
class LanguageNegotiationUrlTest extends BrowserTestBase {
use StringTranslationTrait;
public static $modules = [
'language',
'node',
'path',
];
protected $defaultTheme = 'stark';
protected $user;
protected function setUp() {
parent::setUp();
if ($this->profile != 'standard') {
$this
->drupalCreateContentType([
'type' => 'article',
]);
}
$this->user = $this
->drupalCreateUser([
'administer languages',
'access administration pages',
'view the administration theme',
'administer nodes',
'create article content',
'create url aliases',
]);
$this
->drupalLogin($this->user);
$this
->drupalPostForm('admin/config/regional/language/add', [
'predefined_langcode' => 'de',
], $this
->t('Add language'));
}
public function testDomain() {
$edit = [
'language_negotiation_url_part' => 'domain',
'prefix[en]' => 'eng',
'prefix[de]' => 'de',
'domain[en]' => $_SERVER['HTTP_HOST'],
'domain[de]' => "de.{$_SERVER['HTTP_HOST']}",
];
$this
->drupalPostForm('admin/config/regional/language/detection/url', $edit, $this
->t('Save configuration'));
$nodeValues = [
'title[0][value]' => 'Test',
'path[0][alias]' => '/eng/test',
];
$this
->drupalPostForm('node/add/article', $nodeValues, $this
->t('Save'));
$this
->assertSession()
->statusCodeEquals(200);
}
}