function ConfigSourceListTest::testViewTranslation

File

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

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
    ->assertSession()
    ->pageTextContains('View overview (Config Entity)');

  // Request a translation for archive.
  $edit = array(
    'items[views.view.archive]' => TRUE,
  );
  $this
    ->submitForm($edit, 'Request translation');

  // Verify that we are on the translate tab.
  $this
    ->assertSession()
    ->pageTextContains('One job needs to be checked out.');
  $this
    ->assertSession()
    ->pageTextContains('Archive view (English to ?, Unprocessed)');

  // Submit.
  $this
    ->submitForm([], 'Submit to provider');

  // Make sure that we're back on the originally defined destination URL.
  $this
    ->assertSession()
    ->addressEquals('admin/tmgmt/sources/config/view');
  $this
    ->assertSession()
    ->pageTextContains('Test translation created.');
  $this
    ->assertSession()
    ->pageTextContains('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
    ->submitForm($edit, 'Request translation');

  // Verify that we are on the translate tab.
  $this
    ->assertSession()
    ->pageTextContains('One job needs to be checked out.');
  $this
    ->assertSession()
    ->pageTextContains('Archive view and 3 more (English to ?, Unprocessed)');
  $this
    ->assertSession()
    ->pageTextContains('1 item conflicts with pending item and will be dropped on submission. Conflicting item: Archive view.');

  // Submit.
  $this
    ->submitForm([], 'Submit to provider');

  // Make sure that we're back on the originally defined destination URL.
  $this
    ->assertSession()
    ->addressEquals('admin/tmgmt/sources/config/view');
  $this
    ->assertSession()
    ->pageTextContains('Test translation created.');
  $this
    ->assertSession()
    ->pageTextNotContains('The translation of Archive view to German is finished and can now be reviewed.');
  $this
    ->assertSession()
    ->pageTextContains('The translation of Recent content view to German is finished and can now be reviewed.');
  $this
    ->assertSession()
    ->pageTextContains('The translation of Content view to German is finished and can now be reviewed.');
  $this
    ->assertSession()
    ->pageTextContains('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
    ->submitForm($edit, '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
    ->assertStringContainsString('Cart', $cart_tab_active
    ->getText());
  $this
    ->assertSession()
    ->titleEquals('Cart | Drupal');
  $this
    ->assertSession()
    ->pageTextContains('Request translation');
}