You are here

class LanguageNegotiationUrlTest in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/language/tests/src/Functional/LanguageNegotiationUrlTest.php \Drupal\Tests\language\Functional\LanguageNegotiationUrlTest
  2. 9 core/modules/language/tests/src/Functional/LanguageNegotiationUrlTest.php \Drupal\Tests\language\Functional\LanguageNegotiationUrlTest

@coversDefaultClass \Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationUrl @group language

Hierarchy

Expanded class hierarchy of LanguageNegotiationUrlTest

File

core/modules/language/tests/src/Functional/LanguageNegotiationUrlTest.php, line 11

Namespace

Drupal\Tests\language\Functional
View source
class LanguageNegotiationUrlTest extends BrowserTestBase {

  /**
   * {@inheritdoc}
   */
  protected static $modules = [
    'language',
    'node',
    'path',
  ];

  /**
   * {@inheritdoc}
   */
  protected $defaultTheme = 'stark';

  /**
   * @var \Drupal\user\Entity\User
   */
  protected $user;

  /**
   * {@inheritdoc}
   */
  protected function setUp() : void {
    parent::setUp();

    // Create an Article node type.
    if ($this->profile != 'standard') {
      $this
        ->drupalCreateContentType([
        'type' => 'article',
      ]);
    }
    $this->user = $this
      ->drupalCreateUser([
      'administer languages',
      'access administration pages',
      'view the administration theme',
      'administer nodes',
      'create article content',
      'create url aliases',
    ]);
    $this
      ->drupalLogin($this->user);
    $this
      ->drupalGet('admin/config/regional/language/add');
    $this
      ->submitForm([
      'predefined_langcode' => 'de',
    ], 'Add language');
  }

  /**
   * @covers ::processInbound
   */
  public function testDomain() {

    // Check if paths that contain language prefixes can be reached when
    // language is taken from the domain.
    $edit = [
      'language_negotiation_url_part' => 'domain',
      'prefix[en]' => 'eng',
      'prefix[de]' => 'de',
      'domain[en]' => $_SERVER['HTTP_HOST'],
      'domain[de]' => "de.{$_SERVER['HTTP_HOST']}",
    ];
    $this
      ->drupalGet('admin/config/regional/language/detection/url');
    $this
      ->submitForm($edit, 'Save configuration');
    $nodeValues = [
      'title[0][value]' => 'Test',
      'path[0][alias]' => '/eng/test',
    ];
    $this
      ->drupalGet('node/add/article');
    $this
      ->submitForm($nodeValues, 'Save');
    $this
      ->assertSession()
      ->statusCodeEquals(200);
  }

}

Members