You are here

public function TMGMTUiTest::testSuggestions in Translation Management Tool 8

Tests the UI of suggestions.

File

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

Class

TMGMTUiTest
Verifies basic functionality of the user interface

Namespace

Drupal\Tests\tmgmt\Functional

Code

public function testSuggestions() {

  // Prepare a job and a node for testing.
  $job = $this
    ->createJob();
  $job
    ->addItem('test_source', 'test', 1);
  $job
    ->addItem('test_source', 'test', 7);

  // Go to checkout form.
  $this
    ->drupalGet($job
    ->toUrl());
  $this
    ->assertRaw('20');

  // Verify that suggestions are immediately visible.
  $this
    ->assertText('test_source:test_suggestion:1');
  $this
    ->assertText('test_source:test_suggestion:7');
  $this
    ->assertText('Test suggestion for test source 1');
  $this
    ->assertText('Test suggestion for test source 7');

  // Add the second suggestion.
  $edit = array(
    'suggestions_table[2]' => TRUE,
  );
  $this
    ->drupalPostForm(NULL, $edit, t('Add suggestions'));

  // Total word count should now include the added job.
  $this
    ->assertRaw('31');

  // The suggestion for 7 was added, so there should now be a suggestion
  // for the suggestion instead.
  $this
    ->assertNoText('Test suggestion for test source 7');
  $this
    ->assertText('test_source:test_suggestion_suggestion:7');

  // The HTML test source does not provide suggestions, ensure that the
  // suggestions UI does not show up if there are none.
  $job = $this
    ->createJob();
  $job
    ->addItem('test_html_source', 'test', 1);
  $this
    ->drupalGet($job
    ->toUrl());
  $this
    ->assertNoText('Suggestions');
}