function ConfigSourceUiTest::testCart

Test the entity source specific cart functionality.

File

sources/tmgmt_config/tests/src/Functional/ConfigSourceUiTest.php, line 328

Class

ConfigSourceUiTest
Content entity source UI tests.

Namespace

Drupal\Tests\tmgmt_config\Functional

Code

function testCart() {
  $this
    ->loginAsTranslator(array(
    'translate configuration',
  ));

  // Test the source overview.
  $this
    ->drupalGet('admin/structure/views/view/content/translate');
  $this
    ->submitForm([], 'Add to cart');
  $this
    ->drupalGet('admin/structure/types/manage/article/translate');
  $this
    ->submitForm([], 'Add to cart');

  // Test if the content and article are in the cart.
  $this
    ->drupalGet('admin/tmgmt/cart');
  $this
    ->assertSession()
    ->linkExists('Content view');
  $this
    ->assertSession()
    ->linkExists('Article content type');

  // Test the label on the source overivew.
  $this
    ->drupalGet('admin/structure/views/view/content/translate');
  $this
    ->assertSession()
    ->responseContains(t('There are @count items in the <a href=":url">translation cart</a> including the current item.', array(
    '@count' => 2,
    ':url' => Url::fromRoute('tmgmt.cart')
      ->toString(),
  )));
}