Skip to content
Snippets Groups Projects
Commit 5cf45422 authored by Dave Reid's avatar Dave Reid
Browse files

Fixes and cleanups to tests.

parent 69749bc8
No related branches found
No related tags found
No related merge requests found
......@@ -33,7 +33,7 @@ function feeds_page() {
}
}
if (empty($rows)) {
drupal_set_message(t('There are no importers, go to !importers to create one or enable an existing one.', array('!importers' => l(t('Feeds importers'), 'admin/structure/feeds'))));
drupal_set_message(t('There are no importers, go to <a href="@importers">Feed importers</a> to create one or enable an existing one.', array('@importers' => url('admin/structure/feeds'))));
}
$header = array(
t('Import'),
......
......@@ -11,19 +11,19 @@
class FeedsWebTestCase extends DrupalWebTestCase {
protected $profile = 'testing';
/**
* This override of setUp requires that modules are passed as an array, also
* please don't pass duplicates of what is defined below!
*/
function setUp() {
public function setUp() {
$args = func_get_args();
if (isset($args[0]) && is_array($args[0])) {
// Build the list of required modules which can be altered by passing in an
// array of module names to setUp().
if (isset($args[0])) {
if (is_array($args[0])) {
$modules = $args[0];
}
elseif (count($args) > 1) {
else {
$modules = $args;
}
}
else {
$modules = array();
}
......@@ -35,6 +35,7 @@ class FeedsWebTestCase extends DrupalWebTestCase {
$modules[] = 'field_ui';
$modules[] = 'feeds';
$modules[] = 'feeds_ui';
$modules[] = 'feeds_tests';
$modules[] = 'ctools';
$modules[] = 'job_scheduler';
$modules = array_unique($modules);
......@@ -71,16 +72,26 @@ class FeedsWebTestCase extends DrupalWebTestCase {
$filtered_html_format = (object) $filtered_html_format;
filter_format_save($filtered_html_format);
// Build the list of required administration permissions. Additional
// permissions can be passed as an array into setUp()'s second parameter.
if (isset($args[1]) && is_array($args[1])) {
$permissions = $args[1];
}
else {
$permissions = array();
}
$permissions[] = 'access content';
$permissions[] = 'administer site configuration';
$permissions[] = 'administer content types';
$permissions[] = 'administer nodes';
$permissions[] = 'bypass node access';
$permissions[] = 'administer taxonomy';
$permisisons[] = 'administer users';
$permissions[] = 'administer feeds';
// Create an admin user and log in.
$this->admin_user = $this->drupalCreateUser(array(
'access content',
'administer site configuration',
'administer feeds',
'administer nodes',
'administer content types',
'bypass node access',
'administer users',
));
$this->admin_user = $this->drupalCreateUser($permissions);
$this->drupalLogin($this->admin_user);
$types = array(
......
......@@ -23,13 +23,6 @@ class FeedsDateTimeTest extends DrupalWebTestCase {
);
}
/**
* Set up.
*/
public function setUp() {
parent::setUp('feeds', 'feeds_ui', 'ctools', 'job_scheduler');
}
/**
* Dispatch tests, only use one entry point method testX to save time.
*/
......
......@@ -9,7 +9,6 @@
* File fetcher test class.
*/
class FeedsFileFetcherTestCase extends FeedsWebTestCase {
public static function getInfo() {
return array(
'name' => 'File fetcher',
......
......@@ -12,7 +12,6 @@
* @todo: Add test method for end date
*/
class FeedsMapperDateTestCase extends FeedsMapperTestCase {
public static function getInfo() {
return array(
'name' => 'Mapper: Date',
......@@ -22,11 +21,7 @@ class FeedsMapperDateTestCase extends FeedsMapperTestCase {
);
}
/**
* Set up the test.
*/
public function setUp() {
// Call parent setup with the required module.
parent::setUp(array('date_api', 'date'));
variable_set('date_default_timezone', 'UTC');
}
......
......@@ -9,7 +9,6 @@
* Class for testing Feeds field mapper.
*/
class FeedsMapperFieldTestCase extends FeedsMapperTestCase {
public static function getInfo() {
return array(
'name' => 'Mapper: Fields',
......@@ -18,25 +17,6 @@ class FeedsMapperFieldTestCase extends FeedsMapperTestCase {
);
}
/**
* Set up the test.
*/
function setUp() {
// Call parent setup with required modules.
parent::setUp();
// Create user and login.
$this->drupalLogin($this->drupalCreateUser(array(
'access content',
'administer content types',
'administer feeds',
'administer nodes',
'administer site configuration',
'administer permissions',
'bypass node access',
)));
}
/**
* Basic test loading a double entry CSV file.
*/
......
......@@ -13,7 +13,6 @@
* b) needs to be copied from one location to another.
*/
class FeedsMapperFileTestCase extends FeedsMapperTestCase {
public static function getInfo() {
return array(
'name' => 'Mapper: File field',
......@@ -22,14 +21,6 @@ class FeedsMapperFileTestCase extends FeedsMapperTestCase {
);
}
/**
* Set up the
*/
public function setUp() {
// Call parent setup with the required module
parent::setUp(array('file', 'feeds_tests'));
}
/**
* Basic test loading a single entry CSV file.
*/
......
......@@ -9,7 +9,6 @@
* Class for testing Feeds <em>link</em> mapper.
*/
class FeedsMapperLinkTestCase extends FeedsMapperTestCase {
public static function getInfo() {
return array(
'name' => 'Mapper: Link',
......@@ -19,22 +18,8 @@ class FeedsMapperLinkTestCase extends FeedsMapperTestCase {
);
}
/**
* Set up the test.
*/
public function setUp() {
// Call parent setup with the required module
parent::setUp(array('link'));
// Create user and login
$this->drupalLogin($this->drupalCreateUser(
array(
'administer content types',
'administer feeds',
'bypass node access',
'administer site configuration',
)
));
}
/**
......
......@@ -9,7 +9,6 @@
* Class for testing Feeds <em>content</em> mapper.
*/
class FeedsMapperTaxonomyTestCase extends FeedsMapperTestCase {
public static function getInfo() {
return array(
'name' => 'Mapper: Taxonomy',
......@@ -18,23 +17,8 @@ class FeedsMapperTaxonomyTestCase extends FeedsMapperTestCase {
);
}
/**
* Set up the test.
*/
function setUp() {
// Call parent setup with required modules.
parent::setUp('feeds', 'feeds_ui', 'ctools', 'job_scheduler', 'taxonomy');
// Create user and login.
$this->drupalLogin($this->drupalCreateUser(
array(
'administer content types',
'administer feeds',
'administer nodes',
'administer site configuration',
'administer taxonomy',
)
));
parent::setUp();
// Add a new taxonomy vocabulary, add to article content type.
$edit = array(
......
......@@ -9,7 +9,6 @@
* Test Sitemap parser.
*/
class FeedsSitemapParserTestCase extends FeedsWebTestCase {
public static function getInfo() {
return array(
'name' => 'Sitemap parser',
......@@ -18,21 +17,6 @@ class FeedsSitemapParserTestCase extends FeedsWebTestCase {
);
}
/**
* Set up test.
*/
public function setUp() {
parent::setUp('feeds', 'feeds_ui', 'ctools', 'job_scheduler');
$this->drupalLogin(
$this->drupalCreateUser(
array(
'administer feeds', 'administer nodes',
)
)
);
}
/**
* Run tests.
*/
......
......@@ -9,12 +9,12 @@
* Test single feeds.
*/
class FeedsSyndicationParserTestCase extends FeedsWebTestCase {
public static function getInfo() {
return array(
'name' => 'Syndication parsers',
'description' => 'Regression tests for syndication parsers Common syndication and SimplePie. Tests parsers against a set of feeds in the context of Feeds module. <strong>Requires SimplePie parser to be configured correctly.</strong>',
'group' => 'Feeds',
'dependencies' => array('libraries'),
);
}
......@@ -22,15 +22,7 @@ class FeedsSyndicationParserTestCase extends FeedsWebTestCase {
* Set up test.
*/
public function setUp() {
parent::setUp('feeds', 'feeds_ui', 'ctools', 'job_scheduler', 'libraries');
$this->drupalLogin(
$this->drupalCreateUser(
array(
'administer feeds', 'administer nodes',
)
)
);
parent::setUp(array('libraries'));
}
/**
......
......@@ -25,8 +25,7 @@ class FeedsRSStoNodesTest extends FeedsWebTestCase {
parent::setUp();
// Set the front page to show 20 nodes so we can easily see what is aggregated.
$edit = array('default_nodes_main' => 20);
$this->drupalPost('admin/config/system/site-information', $edit, 'Save configuration');
variable_set('default_nodes_main', 20);
// Set the teaser length display to unlimited otherwise tests looking for
// text on nodes will fail.
......
......@@ -9,7 +9,6 @@
* Test aggregating a feed as data records.
*/
class FeedsCSVtoTermsTest extends FeedsWebTestCase {
public static function getInfo() {
return array(
'name' => 'CSV import to taxonomy',
......@@ -18,19 +17,6 @@ class FeedsCSVtoTermsTest extends FeedsWebTestCase {
);
}
/**
* Set up test.
*/
public function setUp() {
parent::setUp();
$this->drupalLogin($this->drupalCreateUser(array(
'access content',
'administer feeds',
'administer taxonomy',
)));
}
/**
* Test node creation, refreshing/deleting feeds and feed items.
*/
......
......@@ -257,21 +257,4 @@ class FeedsSchedulerTestCase extends FeedsWebTestCase {
$this->cronRun();
$this->assertEqual(84, db_query("SELECT COUNT(*) FROM {node} WHERE type = 'article'")->fetchField());
}
/**
* Helper, log in as an admin user.
*/
protected function loginAdmin() {
$this->drupalLogin($this->admin_user);
}
/**
* Print schedule as notice.
*/
protected function showSchedule() {
$jobs = db_query("SELECT * FROM {job_schedule}");
foreach ($jobs as $job) {
$this->error('<pre>' . print_r($job, true) . '</pre>');
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment