function ConfigSourceListTest::testNodeTypeSubmissions

File

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

Class

ConfigSourceListTest
Tests the user interface for entity translation lists.

Namespace

Drupal\Tests\tmgmt_config\Functional

Code

function testNodeTypeSubmissions() {

  // Simple submission.
  $this
    ->drupalGet('admin/tmgmt/sources/config/node_type');
  $edit = array(
    'items[node.type.article]' => 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('Article content type (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/node_type');
  $this
    ->assertSession()
    ->pageTextContains('Test translation created.');
  $this
    ->assertSession()
    ->pageTextContains('The translation of Article content type to German is finished and can now be reviewed.');

  // Submission of two different entity types.
  $this
    ->drupalGet('admin/tmgmt/sources/config/node_type');
  $edit = array(
    'items[node.type.article]' => TRUE,
    'items[node.type.page]' => TRUE,
  );
  $this
    ->submitForm($edit, 'Request translation');

  // Verify that we are on the translate tab.
  // This is still one job, unlike when selecting more languages.
  $this
    ->assertSession()
    ->pageTextContains('One job needs to be checked out.');
  $this
    ->assertSession()
    ->pageTextContains('Article content type and 1 more (English to ?, Unprocessed)');
  $this
    ->assertSession()
    ->pageTextContains('1 item conflicts with pending item and will be dropped on submission. Conflicting item: Article content type.');

  // 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/node_type');
  $this
    ->assertSession()
    ->pageTextContains('Test translation created.');
  $this
    ->assertSession()
    ->pageTextNotContains('The translation of Article content type to German is finished and can now be reviewed.');
  $this
    ->assertSession()
    ->pageTextContains('The translation of Page content type to German is finished and can now be reviewed.');
}