You are here

public function BulkFormTest::testBulkDeletion in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/modules/node/src/Tests/Views/BulkFormTest.php \Drupal\node\Tests\Views\BulkFormTest::testBulkDeletion()

Test multiple deletion.

File

core/modules/node/src/Tests/Views/BulkFormTest.php, line 214
Contains \Drupal\node\Tests\Views\BulkFormTest.

Class

BulkFormTest
Tests a node bulk form.

Namespace

Drupal\node\Tests\Views

Code

public function testBulkDeletion() {

  // Select a bunch of translated and untranslated nodes and check that
  // nodes and individual translations are properly deleted.
  $edit = array(
    // Original and all translations.
    'node_bulk_form[0]' => TRUE,
    // Node 1, English, original.
    'node_bulk_form[1]' => TRUE,
    // Node 1, British English.
    'node_bulk_form[2]' => TRUE,
    // Node 1, Italian.
    // Original and only one translation.
    'node_bulk_form[3]' => TRUE,
    // Node 2, English.
    'node_bulk_form[4]' => TRUE,
    // Node 2, British English, original.
    'node_bulk_form[5]' => FALSE,
    // Node 2, Italian.
    // Only a single translation.
    'node_bulk_form[6]' => TRUE,
    // Node 3, English.
    'node_bulk_form[7]' => FALSE,
    // Node 3, Italian, original.
    // Only a single untranslated node.
    'node_bulk_form[8]' => TRUE,
    // Node 4, English, untranslated.
    'node_bulk_form[9]' => FALSE,
    // Node 5, British English, untranslated.
    'action' => 'node_delete_action',
  );
  $this
    ->drupalPostForm(NULL, $edit, t('Apply'));
  $label = $this
    ->loadNode(1)
    ->label();
  $this
    ->assertText("{$label} (Original translation) - The following content translations will be deleted:");
  $label = $this
    ->loadNode(2)
    ->label();
  $this
    ->assertText("{$label} (Original translation) - The following content translations will be deleted:");
  $label = $this
    ->loadNode(3)
    ->getTranslation('en')
    ->label();
  $this
    ->assertText($label);
  $this
    ->assertNoText("{$label} (Original translation) - The following content translations will be deleted:");
  $label = $this
    ->loadNode(4)
    ->label();
  $this
    ->assertText($label);
  $this
    ->assertNoText("{$label} (Original translation) - The following content translations will be deleted:");
  $this
    ->drupalPostForm(NULL, array(), t('Delete'));
  $node = $this
    ->loadNode(1);
  $this
    ->assertNull($node, '1: Node has been deleted');
  $node = $this
    ->loadNode(2);
  $this
    ->assertNull($node, '2: Node has been deleted');
  $node = $this
    ->loadNode(3);
  $result = count($node
    ->getTranslationLanguages()) && $node
    ->language()
    ->getId() == 'it';
  $this
    ->assertTrue($result, '3: English translation has been deleted');
  $node = $this
    ->loadNode(4);
  $this
    ->assertNull($node, '4: Node has been deleted');
  $node = $this
    ->loadNode(5);
  $this
    ->assertTrue($node, '5: Node has not been deleted');
  $this
    ->assertText('Deleted 8 posts.');
}