public function LingotekDashboardTest::testDashboardCanAddLanguage in Lingotek Translation 8.2
Same name and namespace in other branches
- 4.0.x tests/src/Functional/LingotekDashboardTest.php \Drupal\Tests\lingotek\Functional\LingotekDashboardTest::testDashboardCanAddLanguage()
- 3.0.x tests/src/Functional/LingotekDashboardTest.php \Drupal\Tests\lingotek\Functional\LingotekDashboardTest::testDashboardCanAddLanguage()
- 3.1.x tests/src/Functional/LingotekDashboardTest.php \Drupal\Tests\lingotek\Functional\LingotekDashboardTest::testDashboardCanAddLanguage()
- 3.2.x tests/src/Functional/LingotekDashboardTest.php \Drupal\Tests\lingotek\Functional\LingotekDashboardTest::testDashboardCanAddLanguage()
- 3.3.x tests/src/Functional/LingotekDashboardTest.php \Drupal\Tests\lingotek\Functional\LingotekDashboardTest::testDashboardCanAddLanguage()
- 3.4.x tests/src/Functional/LingotekDashboardTest.php \Drupal\Tests\lingotek\Functional\LingotekDashboardTest::testDashboardCanAddLanguage()
- 3.5.x tests/src/Functional/LingotekDashboardTest.php \Drupal\Tests\lingotek\Functional\LingotekDashboardTest::testDashboardCanAddLanguage()
- 3.6.x tests/src/Functional/LingotekDashboardTest.php \Drupal\Tests\lingotek\Functional\LingotekDashboardTest::testDashboardCanAddLanguage()
- 3.7.x tests/src/Functional/LingotekDashboardTest.php \Drupal\Tests\lingotek\Functional\LingotekDashboardTest::testDashboardCanAddLanguage()
- 3.8.x tests/src/Functional/LingotekDashboardTest.php \Drupal\Tests\lingotek\Functional\LingotekDashboardTest::testDashboardCanAddLanguage()
Test that a language can be added.
File
- tests/
src/ Functional/ LingotekDashboardTest.php, line 23
Class
- LingotekDashboardTest
- Tests the Lingotek dashboard.
Namespace
Drupal\Tests\lingotek\FunctionalCode
public function testDashboardCanAddLanguage() {
$url = Url::fromRoute('lingotek.dashboard_endpoint')
->setAbsolute()
->toString();
$post = [
'code' => 'it_IT',
'language' => 'Italian',
'native' => 'Italiano',
'direction' => '',
];
$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('it', $response['xcode']);
$this
->assertIdentical('it_IT', $response['locale']);
$this
->assertIdentical(1, $response['active']);
$this
->assertIdentical(1, $response['enabled']);
$this
->assertIdentical(0, $response['source']['total']);
$this
->assertIdentical(0, $response['target']['total']);
$italian_language = ConfigurableLanguage::load('it');
/** @var \Drupal\language\ConfigurableLanguageInterface $italian_language */
$this
->assertNotNull($italian_language, 'Italian language has been added.');
$this
->assertIdentical('Italian', $italian_language
->getName());
$this
->assertIdentical(ConfigurableLanguage::DIRECTION_LTR, $italian_language
->getDirection());
// @ToDo: The native language is not saved.
// $config_translation = \Drupal::languageManager()->getLanguageConfigOverride('it', $italian_language->id());
}