You are here

public function FeedTest::testGetImportedTime in Feeds 8.3

@covers ::getImportedTime @covers ::getNextImportTime

File

tests/src/Kernel/Entity/FeedTest.php, line 103

Class

FeedTest
@coversDefaultClass \Drupal\feeds\Entity\Feed @group feeds

Namespace

Drupal\Tests\feeds\Kernel\Entity

Code

public function testGetImportedTime() {
  $feed = $this
    ->createFeed($this->feedType
    ->id());

  // Since there is nothing imported yet, there is no import time.
  $this
    ->assertSame(0, $feed
    ->getImportedTime());

  // And there is also no next import time yet.
  $this
    ->assertSame(-1, $feed
    ->getNextImportTime());

  // Setup periodic import and import something.
  $this->feedType
    ->set('import_period', 3600);
  $this->feedType
    ->save();
  $feed = $this
    ->reloadFeed($feed);
  $feed
    ->setSource($this
    ->resourcesPath() . '/rss/googlenewstz.rss2');
  $feed
    ->import();
  $this
    ->assertGreaterThanOrEqual(\Drupal::time()
    ->getRequestTime(), $feed
    ->getImportedTime());
  $this
    ->assertSame($feed
    ->getImportedTime() + 3600, $feed
    ->getNextImportTime());
}