Пример #1
0
 /**
  * Tests running "update items" from 'admin/config/services/aggregator' page.
  */
 public function testUpdateFeedItem()
 {
     $this->createSampleNodes();
     // Create a feed and test updating feed items if possible.
     $feed = $this->createFeed();
     if (!empty($feed)) {
         $this->updateFeedItems($feed, $this->getDefaultFeedItemCount());
         $this->deleteFeedItems($feed);
     }
     // Delete feed.
     $this->deleteFeed($feed);
     // Test updating feed items without valid timestamp information.
     $edit = array('title[0][value]' => "Feed without publish timestamp", 'url[0][value]' => $this->getRSS091Sample());
     $this->drupalGet($edit['url[0][value]']);
     $this->assertResponse(200);
     $this->drupalPostForm('aggregator/sources/add', $edit, t('Save'));
     $this->assertRaw(t('The feed %name has been added.', array('%name' => $edit['title[0][value]'])), format_string('The feed @name has been added.', array('@name' => $edit['title[0][value]'])));
     $fid = db_query("SELECT fid FROM {aggregator_feed} WHERE url = :url", array(':url' => $edit['url[0][value]']))->fetchField();
     $feed = Feed::load($fid);
     $feed->refreshItems();
     $before = db_query('SELECT timestamp FROM {aggregator_item} WHERE fid = :fid', array(':fid' => $feed->id()))->fetchField();
     // Sleep for 3 second.
     sleep(3);
     db_update('aggregator_feed')->condition('fid', $feed->id())->fields(array('checked' => 0, 'hash' => '', 'etag' => '', 'modified' => 0))->execute();
     $feed->refreshItems();
     $after = db_query('SELECT timestamp FROM {aggregator_item} WHERE fid = :fid', array(':fid' => $feed->id()))->fetchField();
     $this->assertTrue($before === $after, format_string('Publish timestamp of feed item was not updated (@before === @after)', array('@before' => $before, '@after' => $after)));
     // Make sure updating items works even after uninstalling a module
     // that provides the selected plugins.
     $this->enableTestPlugins();
     $this->container->get('module_installer')->uninstall(array('aggregator_test'));
     $this->updateFeedItems($feed);
     $this->assertResponse(200);
 }
Пример #2
0
 /**
  * Creates an aggregator feed.
  *
  * This method simulates the form submission on path aggregator/sources/add.
  *
  * @param string $feed_url
  *   (optional) If given, feed will be created with this URL, otherwise
  *   /rss.xml will be used. Defaults to NULL.
  * @param array $edit
  *   Array with additional form fields.
  *
  * @return \Drupal\aggregator\FeedInterface
  *   Full feed object if possible.
  *
  * @see getFeedEditArray()
  */
 public function createFeed($feed_url = NULL, array $edit = array())
 {
     $edit = $this->getFeedEditArray($feed_url, $edit);
     $this->drupalPostForm('aggregator/sources/add', $edit, t('Save'));
     $this->assertRaw(t('The feed %name has been added.', array('%name' => $edit['title[0][value]'])), format_string('The feed @name has been added.', array('@name' => $edit['title[0][value]'])));
     $fid = db_query("SELECT fid FROM {aggregator_feed} WHERE title = :title AND url = :url", array(':title' => $edit['title[0][value]'], ':url' => $edit['url[0][value]']))->fetchField();
     $this->assertTrue(!empty($fid), 'The feed found in database.');
     return Feed::load($fid);
 }
Пример #3
0
 /**
  * Creates an aggregator feed.
  *
  * This method simulates the form submission on path aggregator/sources/add.
  *
  * @param string $feed_url
  *   (optional) If given, feed will be created with this URL, otherwise
  *   /rss.xml will be used. Defaults to NULL.
  * @param array $edit
  *   Array with additional form fields.
  *
  * @return \Drupal\aggregator\FeedInterface
  *   Full feed object if possible.
  *
  * @see getFeedEditArray()
  */
 public function createFeed($feed_url = NULL, array $edit = array())
 {
     $edit = $this->getFeedEditArray($feed_url, $edit);
     $this->drupalPostForm('aggregator/sources/add', $edit, t('Save'));
     $this->assertText(t('The feed @name has been added.', array('@name' => $edit['title[0][value]'])), format_string('The feed @name has been added.', array('@name' => $edit['title[0][value]'])));
     // Verify that the creation message contains a link to a feed.
     $view_link = $this->xpath('//div[@class="messages"]//a[contains(@href, :href)]', array(':href' => 'aggregator/sources/'));
     $this->assert(isset($view_link), 'The message area contains a link to a feed');
     $fid = db_query("SELECT fid FROM {aggregator_feed} WHERE title = :title AND url = :url", array(':title' => $edit['title[0][value]'], ':url' => $edit['url[0][value]']))->fetchField();
     $this->assertTrue(!empty($fid), 'The feed found in database.');
     return Feed::load($fid);
 }
Пример #4
0
 /**
  * Test post-processing functionality.
  */
 public function testPostProcess()
 {
     $feed = $this->createFeed(NULL, array('refresh' => 1800));
     $this->updateFeedItems($feed);
     $feed_id = $feed->id();
     // Reset entity cache manually.
     \Drupal::entityManager()->getStorage('aggregator_feed')->resetCache(array($feed_id));
     // Reload the feed to get new values.
     $feed = Feed::load($feed_id);
     // Make sure its refresh rate doubled.
     $this->assertEqual($feed->getRefreshRate(), 3600);
 }
Пример #5
0
 /**
  * Tests migration of aggregator feeds.
  */
 public function testAggregatorFeedImport()
 {
     /** @var \Drupal\aggregator\Entity\Feed $feed */
     $feed = Feed::load(5);
     $this->assertIdentical('Know Your Meme', $feed->title->value);
     $this->assertIdentical('en', $feed->language()->getId());
     $this->assertIdentical('http://knowyourmeme.com/newsfeed.rss', $feed->url->value);
     $this->assertIdentical('900', $feed->refresh->value);
     $this->assertIdentical('1387659487', $feed->checked->value);
     $this->assertIdentical('0', $feed->queued->value);
     $this->assertIdentical('http://knowyourmeme.com', $feed->link->value);
     $this->assertIdentical('New items added to the News Feed', $feed->description->value);
     $this->assertIdentical('http://b.thumbs.redditmedia.com/harEHsUUZVajabtC.png', $feed->image->value);
     $this->assertIdentical('"213cc1365b96c310e92053c5551f0504"', $feed->etag->value);
     $this->assertIdentical('0', $feed->modified->value);
 }
 /**
  * Tests migration of aggregator feeds.
  */
 public function testAggregatorFeedImport()
 {
     /** @var Feed $feed */
     $feed = Feed::load(5);
     $this->assertNotNull($feed->uuid());
     $this->assertEqual($feed->title->value, 'Know Your Meme');
     $this->assertEqual($feed->language()->getId(), 'en');
     $this->assertEqual($feed->url->value, 'http://knowyourmeme.com/newsfeed.rss');
     $this->assertEqual($feed->refresh->value, 900);
     $this->assertEqual($feed->checked->value, 1387659487);
     $this->assertEqual($feed->queued->value, 0);
     $this->assertEqual($feed->link->value, 'http://knowyourmeme.com');
     $this->assertEqual($feed->description->value, 'New items added to the News Feed');
     $this->assertEqual($feed->image->value, 'http://b.thumbs.redditmedia.com/harEHsUUZVajabtC.png');
     $this->assertEqual($feed->hash->value, '');
     $this->assertEqual($feed->etag->value, '"213cc1365b96c310e92053c5551f0504"');
     $this->assertEqual($feed->modified->value, 0);
 }
 /**
  * Tests migration of aggregator feeds.
  */
 public function testAggregatorFeedImport()
 {
     /** @var \Drupal\aggregator\FeedInterface $feed */
     $feed = Feed::load(1);
     $this->assertIdentical('Know Your Meme', $feed->label());
     $this->assertIdentical('en', $feed->language()->getId());
     $this->assertIdentical('http://knowyourmeme.com/newsfeed.rss', $feed->getUrl());
     $this->assertIdentical('900', $feed->getRefreshRate());
     // The feed's last checked time can change as the fixture is updated, so
     // assert that its format is correct.
     $checked_time = $feed->getLastCheckedTime();
     $this->assertTrue(is_numeric($checked_time));
     $this->assertTrue($checked_time > 1000000000);
     $this->assertIdentical('0', $feed->getQueuedTime());
     $this->assertIdentical('http://knowyourmeme.com', $feed->link->value);
     $this->assertIdentical('New items added to the News Feed', $feed->getDescription());
     $this->assertNull($feed->getImage());
     // As with getLastCheckedTime(), the etag can change as the fixture is
     // updated normally, so assert that its format is correct.
     $this->assertTrue(preg_match('/^"[a-z0-9]{32}"$/', $feed->getEtag()));
     $this->assertIdentical('0', $feed->getLastModified());
 }
Пример #8
0
 /**
  * {@inheritdoc}
  */
 public function getCacheTagsToInvalidate()
 {
     return Feed::load($this->getFeedId())->getCacheTags();
 }
Пример #9
0
 /**
  * {@inheritdoc}
  */
 public function getCacheTag()
 {
     return Feed::load($this->getFeedId())->getCacheTag();
 }