You are here

public function CacheFlushUICRUD::operationTest in CacheFlush 7.3

Tests for Bulk Operations.

1 call to CacheFlushUICRUD::operationTest()
CacheFlushUICRUD::testAdminPage in modules/cacheflush_ui/cacheflush_ui.test
Tests List page.

File

modules/cacheflush_ui/cacheflush_ui.test, line 167
Contains test suite for cacheflush ui module.

Class

CacheFlushUICRUD
Test the UI CRUD.

Code

public function operationTest($enabled, $disabled) {
  $this
    ->drupalGet('admin/structure/cacheflush');

  // Check publish and remove menu entry operation.
  $this
    ->drupalPost(NULL, array(
    'operation' => 'enable',
    'presets[' . $disabled->id . ']' => 1,
  ), t('Update'));
  $this
    ->drupalPost(NULL, array(
    'operation' => 'remove_menu_entry',
    'presets[' . $disabled->id . ']' => 1,
  ), t('Update'));
  $disabled_to_enabled = cacheflush_load_multiple(array(
    $disabled->id,
  ), NULL, TRUE);
  $this
    ->assertEqual($disabled_to_enabled[$disabled->id]->status, 1, 'Entity successfully Published.');
  $this
    ->assertEqual($disabled_to_enabled[$disabled->id]->menu, 0, 'Menu entry removed.');

  // Check unpublish and add menu entry operation.
  $this
    ->drupalPost(NULL, array(
    'operation' => 'disable',
    'presets[' . $enabled->id . ']' => 1,
  ), t('Update'));
  $this
    ->drupalPost(NULL, array(
    'operation' => 'add_menu_entry',
    'presets[' . $enabled->id . ']' => 1,
  ), t('Update'));
  $enabled_to_disabled = cacheflush_load_multiple(array(
    $enabled->id,
  ), NULL, TRUE);
  $this
    ->assertEqual($enabled_to_disabled[$enabled->id]->status, 0, 'Entity successfully Unpublished.');
  $this
    ->assertEqual($enabled_to_disabled[$enabled->id]->menu, 1, 'Add menu entry.');

  // Remove the entities.
  $edit = array(
    'operation' => 'delete',
    'presets[' . $enabled->id . ']' => 1,
    'presets[' . $disabled->id . ']' => 1,
  );
  $this
    ->drupalPost(NULL, $edit, t('Update'));
  $this
    ->assertLink(t('Cancel'));
  $this
    ->assertFieldByName('op', t('Delete'));
  $this
    ->drupalPost(NULL, array(), t('Delete'));
  $entities = array_values(cacheflush_load_multiple(FALSE));
  $this
    ->assertEqual(count($entities), 0, 'Entity successfully deleted.');
}