function ConfigSourceUiTest::testNodeTypeTranslateTabMultipeCheckout

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
    ->assertSession()
    ->pageTextContains('Translations of Article content type');
  $this
    ->assertSession()
    ->pageTextContains('There are 0 items in the translation cart.');

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

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

  // Submit all jobs.
  $this
    ->assertSession()
    ->pageTextContains('Article content type (English to German, Unprocessed)');
  $this
    ->submitForm([], 'Submit to provider and continue');
  $this
    ->assertSession()
    ->pageTextContains('Article content type (English to Spanish, Unprocessed)');
  $this
    ->submitForm([], 'Submit to provider');

  // Make sure that we're back on the translate tab.
  $this
    ->assertSession()
    ->addressEquals('admin/structure/types/manage/article/translate');
  $this
    ->assertSession()
    ->pageTextContains('Test translation created.');
  $this
    ->assertSession()
    ->pageTextNotContains(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
    ->assertEquals(2, $counter);
}