You are here

function ConfigSourceListTest::testViewTranslation in Translation Management Tool 8

File

sources/tmgmt_config/tests/src/Functional/ConfigSourceListTest.php, line 97

Class

ConfigSourceListTest
Tests the user interface for entity translation lists.

Namespace

Drupal\Tests\tmgmt_config\Functional

Code

function testViewTranslation() {

  // Check if we have appropriate message in case there are no entity
  // translatable content types.
  $this
    ->drupalGet('admin/tmgmt/sources/config/view');
  $this
    ->assertText(t('View overview (Config Entity)'));

  // Request a translation for archive.
  $edit = array(
    'items[views.view.archive]' => 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(t('Archive view (English to ?, 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/tmgmt/sources/config/view');
  $this
    ->assertText(t('Test translation created.'));
  $this
    ->assertText(t('The translation of Archive view to German is finished and can now be reviewed.'));

  // Request a translation for more archive, recent comments, content and job
  // overview.
  $edit = array(
    'items[views.view.archive]' => TRUE,
    'items[views.view.content_recent]' => TRUE,
    'items[views.view.content]' => TRUE,
    'items[views.view.tmgmt_job_overview]' => 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(t('Archive view and 3 more (English to ?, Unprocessed)'));
  $this
    ->assertText('1 item conflicts with pending item and will be dropped on submission. Conflicting item: Archive view.');

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

  // Make sure that we're back on the originally defined destination URL.
  $this
    ->assertUrl('admin/tmgmt/sources/config/view');
  $this
    ->assertText(t('Test translation created.'));
  $this
    ->assertNoText(t('The translation of Archive view to German is finished and can now be reviewed.'));
  $this
    ->assertText(t('The translation of Recent content view to German is finished and can now be reviewed.'));
  $this
    ->assertText(t('The translation of Content view to German is finished and can now be reviewed.'));
  $this
    ->assertText(t('The translation of Job overview view to German is finished and can now be reviewed.'));

  // Make sure that the Cart page works.
  $edit = array(
    'items[views.view.tmgmt_job_items]' => TRUE,
  );
  $this
    ->drupalPostForm(NULL, $edit, t('Add to cart'));
  $this
    ->clickLink('cart');

  // Verify that we are on the Cart page.
  $cart_tab_active = $this
    ->xpath('//ul[@class="tabs primary"]/li[@class="is-active"]/a')[0];
  $this
    ->assertEquals('Cart(active tab)', $cart_tab_active
    ->getText());
  $this
    ->assertTitle('Cart | Drupal');
  $this
    ->assertText('Request translation');
}