1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
<?php
declare(strict_types=1);
namespace Drupal\Tests\language\Functional;
use Drupal\Tests\BrowserTestBase;
/**
* @coversDefaultClass \Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationUrl
* @group language
*/
class LanguageNegotiationUrlTest extends BrowserTestBase {
/**
* {@inheritdoc}
*/
protected static $modules = [
'language',
'node',
'path',
];
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* @var \Drupal\user\Entity\User
*/
protected $user;
/**
* {@inheritdoc}
*/
protected function setUp(): void {
parent::setUp();
// Create an Article node type.
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->drupalGet('admin/config/regional/language/add');
$this->submitForm(['predefined_langcode' => 'de'], 'Add language');
}
/**
* @covers ::processInbound
*/
public function testDomain(): void {
// Check if paths that contain language prefixes can be reached when
// language is taken from the domain.
$edit = [
'language_negotiation_url_part' => 'domain',
'prefix[en]' => 'eng',
'prefix[de]' => 'de',
'domain[en]' => $_SERVER['HTTP_HOST'],
'domain[de]' => "de.$_SERVER[HTTP_HOST]",
];
$this->drupalGet('admin/config/regional/language/detection/url');
$this->submitForm($edit, 'Save configuration');
$nodeValues = [
'title[0][value]' => 'Test',
'path[0][alias]' => '/eng/test',
];
$this->drupalGet('node/add/article');
$this->submitForm($nodeValues, 'Save');
$this->assertSession()->statusCodeEquals(200);
}
}
|