public function ExpireTest::testExpireItemsWithBatch in Feeds 8.3
Tests expiring items when doing an import in the UI.
File
- tests/
src/ Functional/ ExpireTest.php, line 49
Class
- ExpireTest
- Tests the expire feature.
Namespace
Drupal\Tests\feeds\FunctionalCode
public function testExpireItemsWithBatch() {
// Create a feed and import first file.
$feed = $this
->createFeed($this->feedType
->id(), [
'source' => $this
->resourcesPath() . '/rss/googlenewstz.rss2',
]);
$this
->batchImport($feed);
// Reload feed and assert that 6 nodes have been created.
$feed = $this
->reloadFeed($feed);
static::assertEquals(6, $feed
->getItemCount());
$this
->assertNodeCount(6);
// Set import time to be about an hour in the past.
\Drupal::database()
->update('node__feeds_item')
->fields([
'feeds_item_imported' => $this->container
->get('datetime.time')
->getRequestTime() - 3601,
])
->execute();
// Import an "updated" version of the file from which one item is removed.
$feed
->setSource($this
->resourcesPath() . '/rss/googlenewstz_missing.rss2');
$feed
->save();
$this
->batchImport($feed);
// Assert that one node is removed.
$feed = $this
->reloadFeed($feed);
$this
->assertText('Expired 1 items.');
static::assertEquals(5, $feed
->getItemCount());
$this
->assertNodeCount(5);
// And assert that the feed is no longer locked.
$this
->assertFalse($feed
->isLocked());
}