You are here

public function DisplayJsonFeedTest::testFeedPagnation in JSON Feed 8

Test feed item pagination.

File

tests/src/Functional/DisplayJsonFeedTest.php, line 177

Class

DisplayJsonFeedTest
Tests the json_feed display plugin.

Namespace

Drupal\Tests\json_feed\Functional

Code

public function testFeedPagnation() {
  $feed_content = Json::decode($this
    ->drupalGet($this->feedPath, [
    'query' => [
      '_format' => 'json',
    ],
  ]));
  if ($this->feedItemsPerPage < $this->nodesToCreate) {
    $this
      ->assertTrue(array_key_exists('next_url', $feed_content), 'JSON Feed next_url attribute present.');
  }
  else {
    $this
      ->assertFalse(array_key_exists('next_url', $feed_content), 'JSON Feed next_url attribute not present.');
  }
  $this
    ->assertEqual($this
    ->expectedFirstPageItems(), count($feed_content['items']), 'JSON Feed first page returned ' . $this
    ->expectedFirstPageItems() . ' items.');
}