You are here

public function UserProtectViewsBulkOperationsWebTest::testDeleteProtection in User protect 7

Tests if users that may not be deleted, can not be deleted in bulk.

File

tests/UserProtectViewsBulkOperationsWebTest.test, line 162
Contains UserProtectViewsBulkOperationsWebTest.

Class

UserProtectViewsBulkOperationsWebTest
Tests if user bulk operations provided by Views Bulk Operations are protected.

Code

public function testDeleteProtection() {

  // Create an user with delete protection.
  $protected_account = $this
    ->createProtectedUser(array(
    'up_cancel' => 1,
  ));

  // Try to delete the account.
  $edit = array(
    'views_bulk_operations[' . ($protected_account->uid - 1) . ']' => TRUE,
    'operation' => 'action::views_bulk_operations_delete_item',
  );
  $this
    ->drupalPost('test-user-bulk-form', $edit, t('Execute'));

  // Ensure the protected account still exists.
  $protected_account = user_load($protected_account->uid, TRUE);
  $this
    ->assertTrue(!empty($protected_account->uid), 'The protected user is not deleted.');
}