You are here

public function FeedsModuleInstallUninstallWebTest::testJobsRemovalOnUninstall in Feeds 7.2

Tests if scheduled jobs are removed when uninstalling Feeds.

File

tests/feeds_install.test, line 66

Class

FeedsModuleInstallUninstallWebTest
Tests module installation and uninstallation.

Code

public function testJobsRemovalOnUninstall() {

  // Create a Feeds importer.
  $id = 'syndication';
  $importer = feeds_importer($id);
  $importer
    ->addConfig(array(
    'name' => 'Syndication',
  ));

  // Set processor config to expire nodes.
  $importer->processor
    ->addConfig(array(
    'expire' => 3600,
  ));
  $importer
    ->save();

  // Login as admin.
  $admin = $this
    ->drupalCreateUser(array(
    'access content',
    'administer feeds',
  ));
  $this
    ->drupalLogin($admin);

  // Import URL.
  $edit = array(
    'feeds[FeedsHTTPFetcher][source]' => $GLOBALS['base_url'] . '/' . drupal_get_path('module', 'feeds') . '/tests/feeds/developmentseed.rss2',
  );
  $this
    ->drupalPost('import/' . $id, $edit, 'Import');

  // Check whether feed got properly added to scheduler.
  $this
    ->assertEqual(1, db_query("SELECT COUNT(*) FROM {job_schedule} WHERE type = :id AND id = 0 AND name = 'feeds_source_import' AND last <> 0 AND scheduled = 0", array(
    ':id' => $id,
  ))
    ->fetchField());

  // Check expire scheduler.
  $this
    ->assertEqual(1, db_query("SELECT COUNT(*) FROM {job_schedule} WHERE type = :id AND id = 0 AND name = 'feeds_source_expire'", array(
    ':id' => $id,
  ))
    ->fetchField());

  // Now uninstall Feeds.
  $this
    ->uninstallFeeds();

  // Check that all Feeds jobs are removed from the scheduler.
  $this
    ->assertEqual(0, db_query("SELECT COUNT(*) FROM {job_schedule} WHERE name LIKE 'feeds_%'")
    ->fetchField());
}