You are here

function ConfigSourceUiTest::testSimpleConfiguration in Translation Management Tool 8

Test the node type for a single checkout.

File

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

Class

ConfigSourceUiTest
Content entity source UI tests.

Namespace

Drupal\Tests\tmgmt_config\Functional

Code

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

  // Go to the translate tab.
  $this
    ->drupalGet('admin/config/system/site-information/translate');

  // Assert some basic strings on that page.
  $this
    ->assertText(t('Translations of System information'));

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

  // Verify that we are on the translate tab.
  $this
    ->assertText(t('One job needs to be checked out.'));
  $this
    ->assertText('System information (English to German, Unprocessed)');

  // Submit.
  $this
    ->drupalPostForm(NULL, array(), t('Submit to provider'));

  // Make sure that we're back on the originally defined destination URL.
  $this
    ->assertUrl('admin/config/system/site-information/translate');

  // We are redirected back to the correct page.
  $this
    ->drupalGet('admin/config/system/site-information/translate');

  // Translated languages should now be listed as Needs review.
  $rows = $this
    ->xpath('//tbody/tr');
  $found = FALSE;
  foreach ($rows as $value) {
    $image = $value
      ->find('css', 'td:nth-child(3) a img');
    if ($image && $image
      ->getAttribute('title') == 'Needs review') {
      $found = TRUE;
      $this
        ->assertEquals('German', $value
        ->find('css', 'td:nth-child(2)')
        ->getText());
    }
  }
  $this
    ->assertTrue($found);

  // Verify that the pending translation is shown.
  $this
    ->clickLinkWithImageTitle('Needs review');
  $this
    ->drupalPostForm(NULL, array(
    'name[translation]' => 'de_Druplicon',
  ), t('Save'));
  $this
    ->clickLinkWithImageTitle('Needs review');
  $this
    ->assertText('de_Druplicon');
  $this
    ->drupalPostForm(NULL, array(), t('Save'));

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

  // Verify that we are on the checkout page.
  $this
    ->assertText(t('One job needs to be checked out.'));
  $this
    ->assertText('System information (English to Spanish, Unprocessed)');
  $this
    ->drupalPostForm(NULL, array(), t('Submit to provider'));

  // Make sure that we're back on the originally defined destination URL.
  $this
    ->assertUrl('admin/config/system/site-information/translate');

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

  // Test translation and validation tags of account settings.
  $this
    ->drupalGet('admin/config/people/accounts/translate');
  $this
    ->drupalPostForm(NULL, [
    'languages[de]' => TRUE,
  ], t('Request translation'));

  // Submit.
  $this
    ->drupalPostForm(NULL, array(), t('Submit to provider'));
  $this
    ->clickLinkWithImageTitle('Needs review');
  $this
    ->drupalPostForm(NULL, array(
    'user__settings|anonymous[translation]' => 'de_Druplicon',
  ), t('Validate HTML tags'));
  $this
    ->assertText('de_Druplicon');
  $this
    ->drupalPostForm(NULL, array(), t('Save'));
  $this
    ->clickLinkWithImageTitle('Needs review');
  $this
    ->assertText('de_Druplicon');
}