You are here

function ConfigSourceUiTest::testNodeTypeTranslateTabMultipeCheckout in Translation Management Tool 8

Test the node type for a single checkout.

File

sources/tmgmt_config/tests/src/Functional/ConfigSourceUiTest.php, line 149

Class

ConfigSourceUiTest
Content entity source UI tests.

Namespace

Drupal\Tests\tmgmt_config\Functional

Code

function testNodeTypeTranslateTabMultipeCheckout() {
  $this
    ->loginAsTranslator(array(
    'translate configuration',
  ));

  // Go to the translate tab.
  $this
    ->drupalGet('admin/structure/types/manage/article/translate');

  // Assert some basic strings on that page.
  $this
    ->assertText(t('Translations of Article content type'));
  $this
    ->assertText(t('There are 0 items in the translation cart.'));

  // Request a translation for german and spanish.
  $edit = array(
    'languages[de]' => TRUE,
    'languages[es]' => TRUE,
  );
  $this
    ->drupalPostForm(NULL, $edit, t('Request translation'));

  // Verify that we are on the translate tab.
  $this
    ->assertText(t('2 jobs need to be checked out.'));

  // Submit all jobs.
  $this
    ->assertText('Article content type (English to German, Unprocessed)');
  $this
    ->drupalPostForm(NULL, array(), t('Submit to provider and continue'));
  $this
    ->assertText('Article content type (English to Spanish, Unprocessed)');
  $this
    ->drupalPostForm(NULL, array(), t('Submit to provider'));

  // Make sure that we're back on the translate tab.
  $this
    ->assertUrl('admin/structure/types/manage/article/translate');
  $this
    ->assertText(t('Test translation created.'));
  $this
    ->assertNoText(t('The translation of @title to @language is finished and can now be reviewed.', array(
    '@title' => 'Article',
    '@language' => t('Spanish'),
  )));

  // Translated languages should now be listed as Needs review.
  $rows = $this
    ->xpath('//tbody/tr');
  $counter = 0;
  foreach ($rows as $element) {
    $language = $element
      ->find('css', 'td:nth-child(2)')
      ->getText();
    if ('Spanish' == $language || 'German' == $language) {
      $this
        ->assertEquals('Needs review', $element
        ->find('css', 'td:nth-child(3) a img')
        ->getAttribute('title'));
      $counter++;
    }
  }
  $this
    ->assertEqual($counter, 2);
}