FeedProcessorPluginTest.php in Zircon Profile 8
File
core/modules/aggregator/src/Tests/FeedProcessorPluginTest.php
View source
<?php
namespace Drupal\aggregator\Tests;
use Drupal\aggregator\Entity\Feed;
use Drupal\aggregator\Entity\Item;
class FeedProcessorPluginTest extends AggregatorTestBase {
protected function setUp() {
parent::setUp();
$this
->enableTestPlugins();
$this
->createSampleNodes();
}
public function testProcess() {
$feed = $this
->createFeed();
$this
->updateFeedItems($feed);
foreach ($feed->items as $iid) {
$item = Item::load($iid);
$this
->assertTrue(strpos($item
->label(), 'testProcessor') === 0);
}
}
public function testDelete() {
$feed = $this
->createFeed();
$description = $feed->description->value ?: '';
$this
->updateAndDelete($feed, NULL);
$entities = entity_load_multiple_by_properties('aggregator_feed', array(
'description' => $description,
));
$this
->assertTrue(empty($entities));
}
public function testPostProcess() {
$feed = $this
->createFeed(NULL, array(
'refresh' => 1800,
));
$this
->updateFeedItems($feed);
$feed_id = $feed
->id();
\Drupal::entityManager()
->getStorage('aggregator_feed')
->resetCache(array(
$feed_id,
));
$feed = Feed::load($feed_id);
$this
->assertEqual($feed
->getRefreshRate(), 3600);
}
}