Test the node type for a single checkout.
function testViewTranslateTabSingleCheckout() {
$this
->loginAsTranslator(array(
'translate configuration',
));
// Go to the translate tab.
$this
->drupalGet('admin/structure/views/view/content/translate');
// Assert some basic strings on that page.
$this
->assertSession()
->pageTextContains('Translations of Content view');
$this
->assertSession()
->pageTextContains('There are 0 items in the translation cart.');
// Request a translation for german.
$edit = array(
'languages[de]' => 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('Content view (English to German, Unprocessed)');
// Submit.
$this
->submitForm([], 'Submit to provider');
// Make sure that we're back on the originally defined destination URL.
$this
->assertSession()
->addressEquals('admin/structure/views/view/content/translate');
// We are redirected back to the correct page.
$this
->drupalGet('admin/structure/views/view/content/translate');
// Translated languages should now be listed as Needs review.
$rows = $this
->xpath('//tbody/tr');
foreach ($rows as $element) {
if ($element
->find('css', 'td:nth-child(2)')
->getText() == 'German') {
$this
->assertEquals('Needs review', $element
->find('css', 'td:nth-child(3) a img')
->getAttribute('title'));
}
}
// Verify that the pending translation is shown.
$this
->clickLinkWithImageTitle('Needs review');
$this
->submitForm([], 'Save');
// Request a spanish translation.
$edit = array(
'languages[es]' => TRUE,
);
$this
->submitForm($edit, 'Request translation');
// Verify that we are on the checkout page.
$this
->assertSession()
->pageTextContains('One job needs to be checked out.');
$this
->assertSession()
->pageTextContains('Content view (English to Spanish, Unprocessed)');
$this
->submitForm([], 'Submit to provider');
// Make sure that we're back on the originally defined destination URL.
$this
->assertSession()
->addressEquals('admin/structure/views/view/content/translate');
// Translated languages should now be listed as Needs review.
$rows = $this
->xpath('//tbody/tr');
$counter = 0;
foreach ($rows as $element) {
$language = $element
->find('css', 'td:nth-child(2)')
->getText();
if ('Spanish' == $language || 'German' == $language) {
$this
->assertEquals('Needs review', $element
->find('css', 'td:nth-child(3) a img')
->getAttribute('title'));
$counter++;
}
}
$this
->assertEquals(2, $counter);
// Test that a job can not be accepted if the entity does not exist.
$this
->clickLinkWithImageTitle('Needs review');
// Delete the view and assert that the job can not be accepted.
$view_content = View::load('content');
$view_content
->delete();
$this
->submitForm([], 'Save as completed');
$this
->assertSession()
->pageTextContains(t('@id of type @type does not exist, the job can not be completed.', array(
'@id' => $view_content
->id(),
'@type' => $view_content
->getEntityTypeId(),
)));
}