You are here

public function LingotekBulkDeleteTest::testNodeBulkDelete in Lingotek Translation 3.7.x

Same name and namespace in other branches
  1. 8.2 tests/src/Functional/LingotekBulkDeleteTest.php \Drupal\Tests\lingotek\Functional\LingotekBulkDeleteTest::testNodeBulkDelete()
  2. 4.0.x tests/src/Functional/LingotekBulkDeleteTest.php \Drupal\Tests\lingotek\Functional\LingotekBulkDeleteTest::testNodeBulkDelete()
  3. 3.0.x tests/src/Functional/LingotekBulkDeleteTest.php \Drupal\Tests\lingotek\Functional\LingotekBulkDeleteTest::testNodeBulkDelete()
  4. 3.1.x tests/src/Functional/LingotekBulkDeleteTest.php \Drupal\Tests\lingotek\Functional\LingotekBulkDeleteTest::testNodeBulkDelete()
  5. 3.2.x tests/src/Functional/LingotekBulkDeleteTest.php \Drupal\Tests\lingotek\Functional\LingotekBulkDeleteTest::testNodeBulkDelete()
  6. 3.3.x tests/src/Functional/LingotekBulkDeleteTest.php \Drupal\Tests\lingotek\Functional\LingotekBulkDeleteTest::testNodeBulkDelete()
  7. 3.4.x tests/src/Functional/LingotekBulkDeleteTest.php \Drupal\Tests\lingotek\Functional\LingotekBulkDeleteTest::testNodeBulkDelete()
  8. 3.5.x tests/src/Functional/LingotekBulkDeleteTest.php \Drupal\Tests\lingotek\Functional\LingotekBulkDeleteTest::testNodeBulkDelete()
  9. 3.6.x tests/src/Functional/LingotekBulkDeleteTest.php \Drupal\Tests\lingotek\Functional\LingotekBulkDeleteTest::testNodeBulkDelete()
  10. 3.8.x tests/src/Functional/LingotekBulkDeleteTest.php \Drupal\Tests\lingotek\Functional\LingotekBulkDeleteTest::testNodeBulkDelete()

Tests that a node can be deleted in the management page.

File

tests/src/Functional/LingotekBulkDeleteTest.php, line 59

Class

LingotekBulkDeleteTest
Tests for bulk deletion in the bulk management page.

Namespace

Drupal\Tests\lingotek\Functional

Code

public function testNodeBulkDelete() {
  $assert_session = $this
    ->assertSession();

  // Login as admin.
  $this
    ->drupalLogin($this->rootUser);

  // Create three node.
  $edit = [];
  $edit['title[0][value]'] = 'Llamas are cool';
  $edit['body[0][value]'] = 'Llamas are very cool';
  $edit['langcode[0][value]'] = 'en';
  $edit['lingotek_translation_management[lingotek_translation_profile]'] = 'manual';
  $this
    ->saveAndPublishNodeForm($edit);
  $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_management[lingotek_translation_profile]'] = 'manual';
  $this
    ->saveAndPublishNodeForm($edit);
  $edit['title[0][value]'] = 'Llamas should stay';
  $edit['body[0][value]'] = 'Llamas should stay';
  $edit['langcode[0][value]'] = 'en';
  $edit['lingotek_translation_management[lingotek_translation_profile]'] = 'manual';
  $this
    ->saveAndPublishNodeForm($edit);
  $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.
  $assert_session
    ->linkExists('Llamas are cool 2');
  $assert_session
    ->linkExists('Llamas are cool');
  $assert_session
    ->linkExists('Llamas should stay');

  // Mark the first two for deletion.
  $edit = [
    'table[1]' => TRUE,
    'table[2]' => TRUE,
    'table[3]' => FALSE,
    $this
      ->getBulkOperationFormName() => 'delete_nodes',
  ];
  $this
    ->drupalPostForm(NULL, $edit, $this
    ->getApplyActionsButtonLabel());

  // Ensure the confirmation page is shown.
  $this
    ->assertText(t('Are you sure you want to delete these content 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 content items.');
  $assert_session
    ->linkNotExists('Llamas are cool 2');
  $assert_session
    ->linkNotExists('Llamas are cool');
  $assert_session
    ->linkExists('Llamas should stay');
  $this
    ->assertUrl('admin/lingotek/manage/node');
}