You are here

function PathautoBulkUpdateTestCase::testBulkUpdate in Pathauto 7

Same name and namespace in other branches
  1. 6.2 pathauto.test \PathautoBulkUpdateTestCase::testBulkUpdate()

File

./pathauto.test, line 875
Functionality tests for Pathauto.

Class

PathautoBulkUpdateTestCase
Bulk update functionality tests.

Code

function testBulkUpdate() {

  // Create some nodes.
  $this->nodes = array();
  for ($i = 1; $i <= 5; $i++) {
    $node = $this
      ->drupalCreateNode();
    $this->nodes[$node->nid] = $node;
  }

  // Clear out all aliases.
  $this
    ->deleteAllAliases();

  // Bulk create aliases.
  $edit = array(
    'update[node_pathauto_bulk_update_batch_process]' => TRUE,
    'update[user_pathauto_bulk_update_batch_process]' => TRUE,
  );
  $this
    ->drupalPost('admin/config/search/path/update_bulk', $edit, t('Update'));
  $this
    ->assertText('Generated 7 URL aliases.');

  // 5 nodes + 2 users
  // Check that aliases have actually been created.
  foreach ($this->nodes as $node) {
    $this
      ->assertEntityAliasExists('node', $node);
  }
  $this
    ->assertEntityAliasExists('user', $this->admin_user);

  // Add a new node.
  $new_node = $this
    ->drupalCreateNode(array(
    'path' => array(
      'alias' => '',
      'pathauto' => FALSE,
    ),
  ));

  // Run the update again which should not run against any nodes.
  $this
    ->drupalPost('admin/config/search/path/update_bulk', $edit, t('Update'));
  $this
    ->assertText('No new URL aliases to generate.');
  $this
    ->assertNoEntityAliasExists('node', $new_node);
}