diff options
author | Dries Buytaert <dries@buytaert.net> | 2010-08-04 03:54:55 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2010-08-04 03:54:55 +0000 |
commit | d30b2bada72e9377b117dc317ae0a819478f0243 (patch) | |
tree | 9fab81ca4367b3680ae1d7e3aeebd1b232763db6 /modules/aggregator | |
parent | 275553286dd31aa304d02e90053bc3b8a87fec28 (diff) | |
download | brdo-d30b2bada72e9377b117dc317ae0a819478f0243.tar.gz brdo-d30b2bada72e9377b117dc317ae0a819478f0243.tar.bz2 |
- Patch #865970 by swentel: can't assign more than one category to a source.
Diffstat (limited to 'modules/aggregator')
-rw-r--r-- | modules/aggregator/aggregator.module | 4 | ||||
-rw-r--r-- | modules/aggregator/aggregator.test | 56 |
2 files changed, 58 insertions, 2 deletions
diff --git a/modules/aggregator/aggregator.module b/modules/aggregator/aggregator.module index 95ab7674d..b82bb6484 100644 --- a/modules/aggregator/aggregator.module +++ b/modules/aggregator/aggregator.module @@ -547,9 +547,9 @@ function aggregator_save_feed($edit) { if (!empty($edit['category'])) { foreach ($edit['category'] as $cid => $value) { if ($value) { - db_merge('aggregator_category_feed') - ->key(array('fid' => $edit['fid'])) + db_insert('aggregator_category_feed') ->fields(array( + 'fid' => $edit['fid'], 'cid' => $cid, )) ->execute(); diff --git a/modules/aggregator/aggregator.test b/modules/aggregator/aggregator.test index 5ef5e75f1..160f8ba6a 100644 --- a/modules/aggregator/aggregator.test +++ b/modules/aggregator/aggregator.test @@ -150,6 +150,19 @@ class AggregatorTestCase extends DrupalWebTestCase { } /** + * Pull categories from aggregator_category table. + */ + function getCategories() { + $categories = array(); + $result = db_query('SELECT * FROM {aggregator_category}'); + foreach ($result as $category) { + $categories[$category->cid] = $category; + } + return $categories; + } + + + /** * Check if the feed name and url is unique. * * @param $feed_name @@ -297,6 +310,49 @@ class AddFeedTestCase extends AggregatorTestCase { } } +class CategorizeFeedTestCase extends AggregatorTestCase { + public static function getInfo() { + return array( + 'name' => 'Categorize feed functionality', + 'description' => 'Categorize feed test.', + 'group' => 'Aggregator' + ); + } + + /** + * Create a feed and make sure you can add more than one category to it. + */ + function testCategorizeFeed() { + + // Create 2 categories. + $category_1 = array('title' => $this->randomName(10), 'description' => ''); + $this->drupalPost('admin/config/services/aggregator/add/category', $category_1, t('Save')); + $this->assertRaw(t('The category %title has been added.', array('%title' => $category_1['title'])), t('The category %title has been added.', array('%title' => $category_1['title']))); + + $category_2 = array('title' => $this->randomName(10), 'description' => ''); + $this->drupalPost('admin/config/services/aggregator/add/category', $category_2, t('Save')); + $this->assertRaw(t('The category %title has been added.', array('%title' => $category_2['title'])), t('The category %title has been added.', array('%title' => $category_2['title']))); + + // Get categories from database. + $categories = $this->getCategories(); + + // Create a feed and assign 2 categories to it. + $feed = $this->getFeedEditArray(); + $feed['block'] = 5; + foreach ($categories as $cid => $category) { + $feed['category'][$cid] = $cid; + } + + // Use aggregator_save_feed() function to save the feed. + aggregator_save_feed($feed); + $db_feed = db_query("SELECT * FROM {aggregator_feed} WHERE title = :title AND url = :url", array(':title' => $feed['title'], ':url' => $feed['url']))->fetch(); + + // Assert the feed has two categories. + $this->getFeedCategories($db_feed); + $this->assertEqual(count($db_feed->categories), 2, t('Feed has 2 categories')); + } +} + class UpdateFeedTestCase extends AggregatorTestCase { public static function getInfo() { return array( |