public function FeedTest::testStartBatchExpire in Feeds 8.3
@covers ::startBatchExpire
File
- tests/
src/ Kernel/ Entity/ FeedTest.php, line 221
Class
- FeedTest
- @coversDefaultClass \Drupal\feeds\Entity\Feed @group feeds
Namespace
Drupal\Tests\feeds\Kernel\EntityCode
public function testStartBatchExpire() {
// Turn on 'expire' option on feed type so that there's something to expire.
$config = $this->feedType
->getProcessor()
->getConfiguration();
$config['expire'] = 3600;
$this->feedType
->getProcessor()
->setConfiguration($config);
$this->feedType
->save();
// Make sure something is imported first.
$feed = $this
->createFeed($this->feedType
->id(), [
'source' => $this
->resourcesPath() . '/rss/googlenewstz.rss2',
]);
$feed
->import();
// Assert that no batch was started yet.
$this
->assertEquals([], batch_get());
// Start batch expire.
$feed
->startBatchExpire();
// Assert that still no batch was created, since there was nothing to
// expire.
$this
->assertEquals([], batch_get());
// Now manually change the imported time of one node to be in the past.
$node = Node::load(1);
$node->feeds_item->imported = \Drupal::time()
->getRequestTime() - 3601;
$node
->save();
// Start batch expire again and assert that there is a batch now.
$feed
->startBatchExpire();
$batch = batch_get();
$this
->assertCount(1, $batch['sets']);
}