FeedProcessorPluginTest.php in Drupal 8
File
core/modules/aggregator/tests/src/Functional/FeedProcessorPluginTest.php
View source
<?php
namespace Drupal\Tests\aggregator\Functional;
use Drupal\aggregator\Entity\Feed;
use Drupal\aggregator\Entity\Item;
class FeedProcessorPluginTest extends AggregatorTestBase {
protected $defaultTheme = 'stark';
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
->assertStringStartsWith('testProcessor', $item
->label());
}
}
public function testDelete() {
$feed = $this
->createFeed();
$description = $feed->description->value ?: '';
$this
->updateAndDelete($feed, NULL);
$entities = \Drupal::entityTypeManager()
->getStorage('aggregator_feed')
->loadByProperties([
'description' => $description,
]);
$this
->assertTrue(empty($entities));
}
public function testPostProcess() {
$feed = $this
->createFeed(NULL, [
'refresh' => 1800,
]);
$this
->updateFeedItems($feed);
$feed_id = $feed
->id();
\Drupal::entityTypeManager()
->getStorage('aggregator_feed')
->resetCache([
$feed_id,
]);
$feed = Feed::load($feed_id);
$this
->assertEqual($feed
->getRefreshRate(), 3600);
}
}