function LanguageNegotiationUrlTest::testProcessOutboundOutputsRelativePathsForSameDomain
Tests path outbound processing correctly setting relative/absolute paths.
File
-
core/
modules/ language/ tests/ src/ Unit/ LanguageNegotiationUrlTest.php, line 344
Class
- LanguageNegotiationUrlTest
- @coversDefaultClass \Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationUrl @group language
Namespace
Drupal\Tests\language\UnitCode
public function testProcessOutboundOutputsRelativePathsForSameDomain() : void {
$this->languageManager
->expects($this->any())
->method('getCurrentLanguage')
->willReturn($this->languages['en']);
$config = $this->getConfigFactoryStub([
'language.negotiation' => [
'url' => [
'source' => LanguageNegotiationUrl::CONFIG_DOMAIN,
'domains' => [
'de' => 'example.de',
'en' => 'example.com',
],
],
],
]);
$request = Request::create('', 'GET', [], [], [], [
'HTTP_HOST' => 'example.com',
]);
$method = new LanguageNegotiationUrl();
$method->setLanguageManager($this->languageManager);
$method->setConfig($config);
$method->setCurrentUser($this->user);
// Check relative paths are used when the language
// is the current language.
$options = [
'language' => $this->languages['en'],
];
$method->processOutbound('foo', $options, $request);
// $options['absolute'] not set or null equals to FALSE.
$this->assertFalse($options['absolute'] ?? FALSE);
// Check absolute paths are used when the language
// is not the current language.
$options = [
'language' => $this->languages['de'],
];
$method->processOutbound('foo', $options, $request);
$this->assertTrue($options['absolute']);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.