Test the entity source specific cart functionality.
function testCart() {
$this
->loginAsTranslator(array(
'translate any entity',
'create content translations',
));
$nodes = array();
for ($i = 0; $i < 4; $i++) {
$nodes[$i] = $this
->createTranslatableNode('page');
}
// Test the source overview.
$this
->drupalGet('admin/tmgmt/sources/content/node');
$this
->submitForm([
'items[' . $nodes[1]
->id() . ']' => TRUE,
'items[' . $nodes[2]
->id() . ']' => TRUE,
], 'Add to cart');
$this
->drupalGet('admin/tmgmt/cart');
$this
->assertSession()
->pageTextContains($nodes[1]
->getTitle());
$this
->assertSession()
->pageTextContains($nodes[2]
->getTitle());
// Test the translate tab.
$this
->drupalGet('node/' . $nodes[3]
->id() . '/translations');
$this
->assertSession()
->responseContains(t('There are @count items in the <a href=":url">translation cart</a>.', array(
'@count' => 2,
':url' => Url::fromRoute('tmgmt.cart')
->toString(),
)));
$this
->submitForm([], 'Add to cart');
$this
->assertSession()
->responseContains(t('@count content source was added into the <a href=":url">cart</a>.', array(
'@count' => 1,
':url' => Url::fromRoute('tmgmt.cart')
->toString(),
)));
$this
->assertSession()
->responseContains(t('There are @count items in the <a href=":url">translation cart</a> including the current item.', array(
'@count' => 3,
':url' => Url::fromRoute('tmgmt.cart')
->toString(),
)));
// Add nodes and assert that page footer is being shown.
$nodes = array();
for ($i = 0; $i < 50; $i++) {
$nodes[$i] = $this
->createTranslatableNode('page');
}
$this
->drupalGet('admin/tmgmt/sources/content/node');
$this
->assertSession()
->responseContains('<ul class="pager__items js-pager__items">');
$this
->assertCount(5, $this
->xpath('//nav[@class="pager"]/ul[@class="pager__items js-pager__items"]/li/a'));
}