Loading core/modules/block/tests/src/Functional/BlockLanguageTest.php +24 −5 Original line number Diff line number Diff line Loading @@ -23,7 +23,7 @@ class BlockLanguageTest extends BrowserTestBase { * * @var array */ protected static $modules = ['language', 'block', 'content_translation']; protected static $modules = ['language', 'block', 'content_translation', 'node']; /** * {@inheritdoc} Loading @@ -48,6 +48,18 @@ protected function setUp(): void { // Verify that language was added successfully. $this->assertSession()->pageTextContains('French'); // Set path prefixes for both languages. $this->config('language.negotiation')->set('url', [ 'source' => 'path_prefix', 'prefixes' => [ 'en' => 'en', 'fr' => 'fr', ], ])->save(); $this->drupalCreateContentType(['type' => 'page']); $this->drupalCreateNode(); } /** Loading Loading @@ -80,10 +92,12 @@ public function testLanguageBlockVisibility() { // Check that a page has a block. $this->drupalGet('en'); $this->assertSession()->statusCodeEquals(200); $this->assertSession()->pageTextContains('Powered by Drupal'); // Check that a page doesn't has a block for the current language anymore. $this->drupalGet('fr'); $this->assertSession()->statusCodeEquals(200); $this->assertSession()->pageTextNotContains('Powered by Drupal'); } Loading Loading @@ -161,9 +175,10 @@ public function testMultipleLanguageTypes() { $this->submitForm($edit, 'Save block'); // Interface negotiation depends on request arguments. $this->drupalGet('node', ['query' => ['language' => 'en']]); $this->drupalGet('node/1', ['query' => ['language' => 'en']]); $this->assertSession()->statusCodeEquals(200); $this->assertSession()->pageTextNotContains('Powered by Drupal'); $this->drupalGet('node', ['query' => ['language' => 'fr']]); $this->drupalGet('node/1', ['query' => ['language' => 'fr']]); $this->assertSession()->pageTextContains('Powered by Drupal'); // Log in again in order to clear the interface language stored in the Loading @@ -174,8 +189,10 @@ public function testMultipleLanguageTypes() { // Content language does not depend on session/request arguments. // It will fall back on English (site default) and not display the block. $this->drupalGet('en'); $this->assertSession()->statusCodeEquals(200); $this->assertSession()->pageTextNotContains('Powered by Drupal'); $this->drupalGet('fr'); $this->assertSession()->statusCodeEquals(200); $this->assertSession()->pageTextNotContains('Powered by Drupal'); // Change visibility to now depend on content language for this block. Loading @@ -187,9 +204,11 @@ public function testMultipleLanguageTypes() { // Content language negotiation does not depend on request arguments. // It will fall back on English (site default) and not display the block. $this->drupalGet('node', ['query' => ['language' => 'en']]); $this->drupalGet('node/1', ['query' => ['language' => 'en']]); $this->assertSession()->statusCodeEquals(200); $this->assertSession()->pageTextNotContains('Powered by Drupal'); $this->drupalGet('node', ['query' => ['language' => 'fr']]); $this->drupalGet('node/1', ['query' => ['language' => 'fr']]); $this->assertSession()->statusCodeEquals(200); $this->assertSession()->pageTextNotContains('Powered by Drupal'); // Content language negotiation depends on path prefix. Loading Loading
core/modules/block/tests/src/Functional/BlockLanguageTest.php +24 −5 Original line number Diff line number Diff line Loading @@ -23,7 +23,7 @@ class BlockLanguageTest extends BrowserTestBase { * * @var array */ protected static $modules = ['language', 'block', 'content_translation']; protected static $modules = ['language', 'block', 'content_translation', 'node']; /** * {@inheritdoc} Loading @@ -48,6 +48,18 @@ protected function setUp(): void { // Verify that language was added successfully. $this->assertSession()->pageTextContains('French'); // Set path prefixes for both languages. $this->config('language.negotiation')->set('url', [ 'source' => 'path_prefix', 'prefixes' => [ 'en' => 'en', 'fr' => 'fr', ], ])->save(); $this->drupalCreateContentType(['type' => 'page']); $this->drupalCreateNode(); } /** Loading Loading @@ -80,10 +92,12 @@ public function testLanguageBlockVisibility() { // Check that a page has a block. $this->drupalGet('en'); $this->assertSession()->statusCodeEquals(200); $this->assertSession()->pageTextContains('Powered by Drupal'); // Check that a page doesn't has a block for the current language anymore. $this->drupalGet('fr'); $this->assertSession()->statusCodeEquals(200); $this->assertSession()->pageTextNotContains('Powered by Drupal'); } Loading Loading @@ -161,9 +175,10 @@ public function testMultipleLanguageTypes() { $this->submitForm($edit, 'Save block'); // Interface negotiation depends on request arguments. $this->drupalGet('node', ['query' => ['language' => 'en']]); $this->drupalGet('node/1', ['query' => ['language' => 'en']]); $this->assertSession()->statusCodeEquals(200); $this->assertSession()->pageTextNotContains('Powered by Drupal'); $this->drupalGet('node', ['query' => ['language' => 'fr']]); $this->drupalGet('node/1', ['query' => ['language' => 'fr']]); $this->assertSession()->pageTextContains('Powered by Drupal'); // Log in again in order to clear the interface language stored in the Loading @@ -174,8 +189,10 @@ public function testMultipleLanguageTypes() { // Content language does not depend on session/request arguments. // It will fall back on English (site default) and not display the block. $this->drupalGet('en'); $this->assertSession()->statusCodeEquals(200); $this->assertSession()->pageTextNotContains('Powered by Drupal'); $this->drupalGet('fr'); $this->assertSession()->statusCodeEquals(200); $this->assertSession()->pageTextNotContains('Powered by Drupal'); // Change visibility to now depend on content language for this block. Loading @@ -187,9 +204,11 @@ public function testMultipleLanguageTypes() { // Content language negotiation does not depend on request arguments. // It will fall back on English (site default) and not display the block. $this->drupalGet('node', ['query' => ['language' => 'en']]); $this->drupalGet('node/1', ['query' => ['language' => 'en']]); $this->assertSession()->statusCodeEquals(200); $this->assertSession()->pageTextNotContains('Powered by Drupal'); $this->drupalGet('node', ['query' => ['language' => 'fr']]); $this->drupalGet('node/1', ['query' => ['language' => 'fr']]); $this->assertSession()->statusCodeEquals(200); $this->assertSession()->pageTextNotContains('Powered by Drupal'); // Content language negotiation depends on path prefix. Loading