Mercurial > hg > cmmr2012-drupal-site
comparison core/modules/language/tests/src/Functional/LanguageUILanguageNegotiationTest.php @ 5:12f9dff5fda9 tip
Update to Drupal core 8.7.1
author | Chris Cannam |
---|---|
date | Thu, 09 May 2019 15:34:47 +0100 |
parents | a9cd425dd02b |
children |
comparison
equal
deleted
inserted
replaced
4:a9cd425dd02b | 5:12f9dff5fda9 |
---|---|
81 $http_header_browser_fallback = ["Accept-Language" => "$langcode_browser_fallback;q=1"]; | 81 $http_header_browser_fallback = ["Accept-Language" => "$langcode_browser_fallback;q=1"]; |
82 // For setting browser language preference to some unknown. | 82 // For setting browser language preference to some unknown. |
83 $http_header_blah = ["Accept-Language" => "blah;q=1"]; | 83 $http_header_blah = ["Accept-Language" => "blah;q=1"]; |
84 | 84 |
85 // Create a private file for testing accessible by the admin user. | 85 // Create a private file for testing accessible by the admin user. |
86 drupal_mkdir($this->privateFilesDirectory . '/test'); | 86 \Drupal::service('file_system')->mkdir($this->privateFilesDirectory . '/test'); |
87 $filepath = 'private://test/private-file-test.txt'; | 87 $filepath = 'private://test/private-file-test.txt'; |
88 $contents = "file_put_contents() doesn't seem to appreciate empty strings so let's put in some data."; | 88 $contents = "file_put_contents() doesn't seem to appreciate empty strings so let's put in some data."; |
89 file_put_contents($filepath, $contents); | 89 file_put_contents($filepath, $contents); |
90 $file = File::create([ | 90 $file = File::create([ |
91 'uri' => $filepath, | 91 'uri' => $filepath, |
444 $language = new Language(['id' => '']); | 444 $language = new Language(['id' => '']); |
445 $this->drupalGet('', ['language' => $language], $http_header); | 445 $this->drupalGet('', ['language' => $language], $http_header); |
446 | 446 |
447 // Check that the language switcher active link matches the given browser | 447 // Check that the language switcher active link matches the given browser |
448 // language. | 448 // language. |
449 $args = [':id' => 'block-test-language-block', ':url' => \Drupal::url('<front>') . $langcode_browser_fallback]; | 449 $args = [':id' => 'block-test-language-block', ':url' => Url::fromRoute('<front>')->toString() . $langcode_browser_fallback]; |
450 $fields = $this->xpath('//div[@id=:id]//a[@class="language-link is-active" and starts-with(@href, :url)]', $args); | 450 $fields = $this->xpath('//div[@id=:id]//a[@class="language-link is-active" and starts-with(@href, :url)]', $args); |
451 $this->assertSame($fields[0]->getText(), $languages[$langcode_browser_fallback]->getName(), 'The browser language is the URL active language'); | 451 $this->assertSame($fields[0]->getText(), $languages[$langcode_browser_fallback]->getName(), 'The browser language is the URL active language'); |
452 | 452 |
453 // Check that URLs are rewritten using the given browser language. | 453 // Check that URLs are rewritten using the given browser language. |
454 $fields = $this->xpath('//div[@class="site-name"]/a[@rel="home" and @href=:url]', $args); | 454 $fields = $this->xpath('//div[@class="site-name"]/a[@rel="home" and @href=:url]', $args); |