View source
<?php
class FeedsModuleInstallUninstallWebTest extends DrupalWebTestCase {
public static function getInfo() {
return array(
'name' => 'Module installation and uninstallation',
'description' => '',
'group' => 'Feeds',
);
}
public function setUp($modules = array()) {
$modules = array_merge(array(
'feeds',
'feeds_ui',
), $modules);
parent::setUp($modules);
}
protected function uninstallFeeds() {
module_disable(array(
'feeds_ui',
'feeds',
));
drupal_uninstall_modules(array(
'feeds_ui',
'feeds',
));
drupal_static_reset();
drupal_flush_all_caches();
$this
->assertEqual(1, db_query("SELECT COUNT(*) FROM {system} WHERE type = 'module' AND status = 0 AND name = 'feeds_ui' AND schema_version = -1")
->fetchField(), 'Feeds Admin UI is uninstalled.');
$this
->assertEqual(1, db_query("SELECT COUNT(*) FROM {system} WHERE type = 'module' AND status = 0 AND name = 'feeds' AND schema_version = -1")
->fetchField(), 'Feeds is uninstalled.');
}
public function testInstallationAndUninstallation() {
$this
->assertTrue(module_exists('feeds'));
$this
->assertTrue(module_exists('feeds_ui'));
$this
->assertEqual('FeedsHTTPCache', variable_get('cache_class_cache_feeds_http'));
$this
->uninstallFeeds();
$this
->assertNull(variable_get('cache_class_cache_feeds_http'), 'The variable "cache_class_cache_feeds_http" is removed.');
}
public function testJobsRemovalOnUninstall() {
$id = 'syndication';
$importer = feeds_importer($id);
$importer
->addConfig(array(
'name' => 'Syndication',
));
$importer->processor
->addConfig(array(
'expire' => 3600,
));
$importer
->save();
$admin = $this
->drupalCreateUser(array(
'access content',
'administer feeds',
));
$this
->drupalLogin($admin);
$edit = array(
'feeds[FeedsHTTPFetcher][source]' => $GLOBALS['base_url'] . '/' . drupal_get_path('module', 'feeds') . '/tests/feeds/developmentseed.rss2',
);
$this
->drupalPost('import/' . $id, $edit, 'Import');
$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());
$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());
$this
->uninstallFeeds();
$this
->assertEqual(0, db_query("SELECT COUNT(*) FROM {job_schedule} WHERE name LIKE 'feeds_%'")
->fetchField());
}
}