You are here

public function LingotekDashboardTest::testDashboardCanAddLanguage in Lingotek Translation 8

Test that a language can be added.

File

src/Tests/LingotekDashboardTest.php, line 31
Contains \Drupal\lingotek\Tests\LingotekDashboardTest.

Class

LingotekDashboardTest
Tests the Lingotek dashboard.

Namespace

Drupal\lingotek\Tests

Code

public function testDashboardCanAddLanguage() {

  // Login as admin.
  $this
    ->drupalLogin($this->rootUser);
  $post = [
    'code' => 'it_IT',
    'language' => 'Italian',
    'native' => 'Italiano',
    'direction' => '',
  ];
  $request = $this
    ->drupalPost('/admin/lingotek/dashboard_endpoint', 'application/json', $post);
  $response = json_decode($request, true);
  $italian_language = ConfigurableLanguage::load('it');

  /** @var $italian_language ConfigurableLanguageInterface */
  $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());
  $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']);
}