comparison core/modules/language/tests/src/Functional/LanguageNegotiationUrlTest.php @ 0:4c8ae668cc8c

Initial import (non-working)
author Chris Cannam
date Wed, 29 Nov 2017 16:09:58 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:4c8ae668cc8c
1 <?php
2
3 namespace Drupal\Tests\language\Functional;
4
5 use Drupal\Core\StringTranslation\StringTranslationTrait;
6 use Drupal\Tests\BrowserTestBase;
7
8 /**
9 * @coversDefaultClass \Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationUrl
10 * @group language
11 */
12 class LanguageNegotiationUrlTest extends BrowserTestBase {
13
14 use StringTranslationTrait;
15
16 /**
17 * {@inheritdoc}
18 */
19 public static $modules = [
20 'language',
21 'node',
22 'path',
23 ];
24
25 /**
26 * @var \Drupal\user\Entity\User
27 */
28 protected $user;
29
30 /**
31 * {@inheritdoc}
32 */
33 protected function setUp() {
34 parent::setUp();
35
36 // Create an Article node type.
37 if ($this->profile != 'standard') {
38 $this->drupalCreateContentType(['type' => 'article']);
39 }
40
41 $this->user = $this->drupalCreateUser([
42 'administer languages',
43 'access administration pages',
44 'view the administration theme',
45 'administer nodes',
46 'create article content',
47 'create url aliases',
48 ]);
49 $this->drupalLogin($this->user);
50
51 $this->drupalPostForm('admin/config/regional/language/add', ['predefined_langcode' => 'de'], $this->t('Add language'));
52 }
53
54 /**
55 * @covers ::processInbound
56 */
57 public function testDomain() {
58 // Check if paths that contain language prefixes can be reached when
59 // language is taken from the domain.
60 $edit = [
61 'language_negotiation_url_part' => 'domain',
62 'prefix[en]' => 'eng',
63 'prefix[de]' => 'de',
64 'domain[en]' => $_SERVER['HTTP_HOST'],
65 'domain[de]' => "de.$_SERVER[HTTP_HOST]",
66 ];
67 $this->drupalPostForm('admin/config/regional/language/detection/url', $edit, $this->t('Save configuration'));
68
69 $nodeValues = [
70 'title[0][value]' => 'Test',
71 'path[0][alias]' => '/eng/test',
72 ];
73 $this->drupalPostForm('node/add/article', $nodeValues, $this->t('Save'));
74 $this->assertSession()->statusCodeEquals(200);
75 }
76
77 }