bdc63f56b0bf5c85d7714682b925344a5e548e18
[yaffs-website] / web / core / modules / aggregator / tests / src / Functional / FeedProcessorPluginTest.php
1 <?php
2
3 namespace Drupal\Tests\aggregator\Functional;
4
5 use Drupal\aggregator\Entity\Feed;
6 use Drupal\aggregator\Entity\Item;
7
8 /**
9  * Tests the processor plugins functionality and discoverability.
10  *
11  * @group aggregator
12  *
13  * @see \Drupal\aggregator_test\Plugin\aggregator\processor\TestProcessor.
14  */
15 class FeedProcessorPluginTest extends AggregatorTestBase {
16
17   /**
18    * {@inheritdoc}
19    */
20   protected function setUp() {
21     parent::setUp();
22     // Enable test plugins.
23     $this->enableTestPlugins();
24     // Create some nodes.
25     $this->createSampleNodes();
26   }
27
28   /**
29    * Test processing functionality.
30    */
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);
37     }
38   }
39
40   /**
41    * Test deleting functionality.
42    */
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));
50   }
51
52   /**
53    * Test post-processing functionality.
54    */
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);
65   }
66
67 }