You are here

public function CtoolsExportCrudTestCase::testCrudExportRevert in Chaos Tool Suite (ctools) 7

Tests CRUD operation: Revert.

File

tests/ctools_export_test/ctools_export.test, line 118

Class

CtoolsExportCrudTestCase
Tests for the CTools export system.

Code

public function testCrudExportRevert() {

  // Load exportable, will come from database.
  $original_export = ctools_export_crud_load('ctools_export_test', 'overridden_test');
  $this
    ->assertTrue($original_export->export_type === 3, 'Loaded export is overridden.');
  $machine = $original_export->machine;
  ctools_export_crud_delete('ctools_export_test', $original_export);
  $result = db_query("SELECT machine FROM {ctools_export_test} WHERE machine = :machine", array(
    ':machine' => $machine,
  ))
    ->fetchField();
  $this
    ->assertFalse($result, 'The exportable object has been removed from the database.');

  // Clear the static cache.
  ctools_export_load_object_reset('ctools_export_test');

  // Reload the same object.
  $default_export = ctools_export_crud_load('ctools_export_test', 'overridden_test');

  // Check the exportable is now in_code_only.
  $this
    ->assertTrue($default_export->in_code_only, 'The loaded exportable is in the database only.');

  // Make sure the default object loaded matches the same overridden one in
  // the database.
  $this
    ->assertEqual($original_export->machine, $default_export->machine, 'The default exportable has been loaded and matches the overridden exportable.');
}