3 namespace Drupal\Tests\aggregator\Functional;
5 use Drupal\aggregator\Entity\Feed;
6 use Drupal\aggregator\Entity\Item;
9 * Tests the processor plugins functionality and discoverability.
13 * @see \Drupal\aggregator_test\Plugin\aggregator\processor\TestProcessor.
15 class FeedProcessorPluginTest extends AggregatorTestBase {
20 protected function setUp() {
22 // Enable test plugins.
23 $this->enableTestPlugins();
25 $this->createSampleNodes();
29 * Test processing functionality.
31 public function testProcess() {
32 $feed = $this->createFeed();
33 $this->updateFeedItems($feed);
34 foreach ($feed->items as $iid) {
35 $item = Item::load($iid);
36 $this->assertTrue(strpos($item->label(), 'testProcessor') === 0);
41 * Test deleting functionality.
43 public function testDelete() {
44 $feed = $this->createFeed();
45 $description = $feed->description->value ?: '';
46 $this->updateAndDelete($feed, NULL);
47 // Make sure the feed title is changed.
48 $entities = entity_load_multiple_by_properties('aggregator_feed', ['description' => $description]);
49 $this->assertTrue(empty($entities));
53 * Test post-processing functionality.
55 public function testPostProcess() {
56 $feed = $this->createFeed(NULL, ['refresh' => 1800]);
57 $this->updateFeedItems($feed);
58 $feed_id = $feed->id();
59 // Reset entity cache manually.
60 \Drupal::entityManager()->getStorage('aggregator_feed')->resetCache([$feed_id]);
61 // Reload the feed to get new values.
62 $feed = Feed::load($feed_id);
63 // Make sure its refresh rate doubled.
64 $this->assertEqual($feed->getRefreshRate(), 3600);