function TMGMTUiTest::testPageTitles

Test titles of various TMGMT pages.

@todo Miro wants to split this test to specific tests (check)

File

tests/src/Functional/TMGMTUiTest.php, line 702

Class

TMGMTUiTest
Verifies basic functionality of the user interface

Namespace

Drupal\Tests\tmgmt\Functional

Code

function testPageTitles() {
  $this
    ->loginAsAdmin();
  $translator = $this
    ->createTranslator();
  $job = $this
    ->createJob();
  $job->translator = $translator;
  $job->settings = array();
  $job
    ->save();
  $item = $job
    ->addItem('test_source', 'test', 1);

  // Tmgtm settings.
  $this
    ->drupalGet('/admin/tmgmt/settings');
  $this
    ->assertSession()
    ->titleEquals('Settings | Drupal');

  // Manage translators.
  $this
    ->drupalGet('/admin/tmgmt/translators');
  $this
    ->assertSession()
    ->titleEquals('Providers | Drupal');

  // Add Translator.
  $this
    ->drupalGet('/admin/tmgmt/translators/add');
  $this
    ->assertSession()
    ->titleEquals('Add Provider | Drupal');

  // Delete Translators.
  $this
    ->drupalGet('/admin/tmgmt/translators/manage/' . $translator
    ->id() . '/delete');
  $this
    ->assertSession()
    ->titleEquals((string) t('Are you sure you want to delete the provider @label? | Drupal', [
    '@label' => $translator
      ->label(),
  ]));

  // Edit Translators.
  $this
    ->drupalGet('/admin/tmgmt/translators/manage/' . $translator
    ->id());
  $this
    ->assertSession()
    ->titleEquals('Edit provider | Drupal');

  // Delete Job.
  $this
    ->drupalGet('/admin/tmgmt/jobs/' . $job
    ->id() . '/delete');
  $this
    ->assertSession()
    ->titleEquals((string) t('Are you sure you want to delete the translation job @label? | Drupal', [
    '@label' => $job
      ->label(),
  ]));

  // Resubmit Job.
  $this
    ->drupalGet('/admin/tmgmt/jobs/' . $job
    ->id() . '/resubmit');
  $this
    ->assertSession()
    ->titleEquals('Resubmit as a new job? | Drupal');

  // Abort Job.
  $this
    ->drupalGet('/admin/tmgmt/jobs/' . $job
    ->id() . '/abort');
  $this
    ->assertSession()
    ->titleEquals('Abort this job? | Drupal');

  // Edit Job Item.
  $this
    ->drupalGet('/admin/tmgmt/items/' . $job
    ->id());
  $this
    ->assertSession()
    ->titleEquals((string) t('Job item @label | Drupal', [
    '@label' => $item
      ->label(),
  ]));

  // Assert the breadcrumb.
  $this
    ->assertSession()
    ->linkExists('Home');
  $this
    ->assertSession()
    ->linkExists('Administration');
  $this
    ->assertSession()
    ->linkExists('Job overview');
  $this
    ->assertSession()
    ->linkExists($job
    ->label());

  // Translation Sources.
  $this
    ->drupalGet('admin');
  $this
    ->clickLink('Translation');
  $this
    ->assertSession()
    ->titleEquals('Translation | Drupal');
  $this
    ->clickLink('Cart');
  $this
    ->assertSession()
    ->titleEquals('Cart | Drupal');
  $this
    ->clickLink('Jobs');
  $this
    ->assertSession()
    ->titleEquals('Job overview | Drupal');
  $this
    ->clickLink('Sources');
  $this
    ->assertSession()
    ->titleEquals('Translation Sources | Drupal');
}