public function LingotekBulkDeleteTest::testNodeBulkDelete in Lingotek Translation 8
Tests that a node can be deleted in the management page.
File
- src/
Tests/ LingotekBulkDeleteTest.php, line 67
Class
- LingotekBulkDeleteTest
- Tests for bulk deletion in the bulk management page.
Namespace
Drupal\lingotek\TestsCode
public function testNodeBulkDelete() {
// Login as admin.
$this
->drupalLogin($this->rootUser);
// Create three node.
$edit = array();
$edit['title[0][value]'] = 'Llamas are cool';
$edit['body[0][value]'] = 'Llamas are very cool';
$edit['langcode[0][value]'] = 'en';
$edit['lingotek_translation_profile'] = 'manual';
$this
->drupalPostForm('node/add/article', $edit, t('Save and publish'));
$edit['title[0][value]'] = 'Llamas are cool 2';
$edit['body[0][value]'] = 'Llamas are very cool 2';
$edit['langcode[0][value]'] = 'en';
$edit['lingotek_translation_profile'] = 'manual';
$this
->drupalPostForm('node/add/article', $edit, t('Save and publish'));
$edit['title[0][value]'] = 'Llamas should stay';
$edit['body[0][value]'] = 'Llamas should stay';
$edit['langcode[0][value]'] = 'en';
$edit['lingotek_translation_profile'] = 'manual';
$this
->drupalPostForm('node/add/article', $edit, t('Save and publish'));
$this
->goToContentBulkManagementForm();
// Ensure the delete operation is there.
$delete_option = $this
->xpath('//*[@id="edit-operation"]/option[text()="Delete content"]');
$this
->assertIdentical(1, count($delete_option), 'Delete operation must be available');
// Three nodes must be there.
$this
->assertLink('Llamas are cool 2');
$this
->assertLink('Llamas are cool');
$this
->assertLink('Llamas should stay');
// Mark the first two for deletion.
$edit = [
'table[1]' => TRUE,
// Node 1.
'table[2]' => TRUE,
// Node 2.
'table[3]' => FALSE,
// Node 3.
'operation' => 'delete_nodes',
];
$this
->drupalPostForm(NULL, $edit, t('Execute'));
// Ensure the confirmation page is shown.
$this
->assertText(t('Are you sure you want to delete these items?'));
$this
->assertText('Llamas are cool');
$this
->assertText('Llamas are cool 2');
$this
->drupalPostForm(NULL, [], t('Delete'));
// Only one node remains and we are back to the manage page.
$this
->assertText('Deleted 2 posts.');
$this
->assertNoLink('Llamas are cool 2');
$this
->assertNoLink('Llamas are cool');
$this
->assertLink('Llamas should stay');
$this
->assertUrl('admin/lingotek/manage/node');
}