public function StaticGeneratorTest::testDomainNegotiation in Tome 8
@covers \Drupal\tome_static\EventSubscriber\LanguagePathSubscriber::collectPaths
File
- modules/
tome_static/ tests/ src/ Kernel/ StaticGeneratorTest.php, line 155
Class
- StaticGeneratorTest
- Tests that static site generation works.
Namespace
Drupal\Tests\tome_static\KernelCode
public function testDomainNegotiation() {
$this
->config('language.negotiation')
->set('url.source', LanguageNegotiationUrl::CONFIG_DOMAIN)
->set('url.domains', [
'en' => 'example.com',
'fr' => 'example.fr',
])
->save();
$article = Node::create([
'type' => 'article',
'title' => 'My article',
]);
$article
->addTranslation('fr', [
'title' => 'My french article',
]);
$article
->save();
/** @var \Drupal\tome_static\StaticGenerator $static */
$static = \Drupal::service('tome_static.generator');
$this
->assertUnsortedEquals([
'/',
'_entity:node:en:1',
'_entity:user:en:0',
], $static
->getPaths());
$request = Request::create('http://example.fr');
\Drupal::requestStack()
->push($request);
\Drupal::service('language_manager')
->reset();
$this
->assertUnsortedEquals([
'/',
'_entity:node:fr:1',
], $static
->getPaths());
}