You are here

public function LingotekDashboardTest::testDashboardCanAddRTLLanguage in Lingotek Translation 3.8.x

Same name and namespace in other branches
  1. 8.2 tests/src/Functional/LingotekDashboardTest.php \Drupal\Tests\lingotek\Functional\LingotekDashboardTest::testDashboardCanAddRTLLanguage()
  2. 4.0.x tests/src/Functional/LingotekDashboardTest.php \Drupal\Tests\lingotek\Functional\LingotekDashboardTest::testDashboardCanAddRTLLanguage()
  3. 3.0.x tests/src/Functional/LingotekDashboardTest.php \Drupal\Tests\lingotek\Functional\LingotekDashboardTest::testDashboardCanAddRTLLanguage()
  4. 3.1.x tests/src/Functional/LingotekDashboardTest.php \Drupal\Tests\lingotek\Functional\LingotekDashboardTest::testDashboardCanAddRTLLanguage()
  5. 3.2.x tests/src/Functional/LingotekDashboardTest.php \Drupal\Tests\lingotek\Functional\LingotekDashboardTest::testDashboardCanAddRTLLanguage()
  6. 3.3.x tests/src/Functional/LingotekDashboardTest.php \Drupal\Tests\lingotek\Functional\LingotekDashboardTest::testDashboardCanAddRTLLanguage()
  7. 3.4.x tests/src/Functional/LingotekDashboardTest.php \Drupal\Tests\lingotek\Functional\LingotekDashboardTest::testDashboardCanAddRTLLanguage()
  8. 3.5.x tests/src/Functional/LingotekDashboardTest.php \Drupal\Tests\lingotek\Functional\LingotekDashboardTest::testDashboardCanAddRTLLanguage()
  9. 3.6.x tests/src/Functional/LingotekDashboardTest.php \Drupal\Tests\lingotek\Functional\LingotekDashboardTest::testDashboardCanAddRTLLanguage()
  10. 3.7.x tests/src/Functional/LingotekDashboardTest.php \Drupal\Tests\lingotek\Functional\LingotekDashboardTest::testDashboardCanAddRTLLanguage()

Test that a language can be added.

File

tests/src/Functional/LingotekDashboardTest.php, line 94

Class

LingotekDashboardTest
Tests the Lingotek dashboard.

Namespace

Drupal\Tests\lingotek\Functional

Code

public function testDashboardCanAddRTLLanguage() {
  $url = Url::fromRoute('lingotek.dashboard_endpoint')
    ->setAbsolute()
    ->toString();
  $post = [
    'code' => 'ar_AE',
    'language' => 'Arabic',
    'native' => 'العربية',
    'direction' => 'RTL',
  ];
  $request = $this->client
    ->post($url, [
    'body' => http_build_query($post),
    'cookies' => $this->cookies,
    'headers' => [
      'Accept' => 'application/json',
      'Content-Type' => 'application/x-www-form-urlencoded',
    ],
    'http_errors' => FALSE,
  ]);
  $response = json_decode($request
    ->getBody(), TRUE);
  $this
    ->assertIdentical('ar', $response['xcode']);
  $this
    ->assertIdentical('ar_AE', $response['locale']);
  $this
    ->assertIdentical(1, $response['active']);
  $this
    ->assertIdentical(1, $response['enabled']);
  $this
    ->assertIdentical(0, $response['source']['total']);
  $this
    ->assertIdentical(0, $response['target']['total']);
  $arabic_language = ConfigurableLanguage::load('ar');

  /** @var \Drupal\language\ConfigurableLanguageInterface $italian_language */
  $this
    ->assertNotNull($arabic_language, 'Arabic language has been added.');
  $this
    ->assertIdentical('Arabic', $arabic_language
    ->getName());
  $this
    ->assertIdentical(ConfigurableLanguage::DIRECTION_RTL, $arabic_language
    ->getDirection());

  // @ToDo: The native language is not saved.
}