You are here

function BlockHashTestCase::doRehash in Drupal 7

Performs a block rehash and checks several related assertions.

Parameters

$alter_active: Set to TRUE if the block_test module's hook_block_info_alter() implementation is expected to make a change that results in an existing block needing to be resaved to the database. Defaults to FALSE.

1 call to BlockHashTestCase::doRehash()
BlockHashTestCase::testBlockRehash in modules/block/block.test
Tests that block rehashing does not write to the database too often.

File

modules/block/block.test, line 952
Tests for block.module.

Class

BlockHashTestCase
Tests that block rehashing works correctly.

Code

function doRehash($alter_active = FALSE) {
  $saves = 0;
  foreach (_block_rehash() as $block) {
    $module = $block['module'];
    $delta = $block['delta'];
    if ($alter_active && $module == 'block_test' && $delta == 'test_html_id') {
      $this
        ->assertFalse(empty($block['saved']), "{$module} {$delta} saved");
      $saves++;
    }
    else {
      $this
        ->assertTrue(empty($block['saved']), "{$module} {$delta} not saved");
    }
  }
  $this
    ->assertEqual($alter_active, $saves);
}