You are here

public function DisplayJsonFeedTest::testFeedItemAuthor in JSON Feed 8

Test the author feed items.

File

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

Class

DisplayJsonFeedTest
Tests the json_feed display plugin.

Namespace

Drupal\Tests\json_feed\Functional

Code

public function testFeedItemAuthor() {
  $json_response = Json::decode($this
    ->drupalGet($this->feedPath, [
    'query' => [
      '_format' => 'json',
    ],
  ]));
  $item = $json_response['items'][0];
  $this
    ->assertTrue(array_key_exists('author', $item), 'JSON Feed item author attribute present.');
  $author_info = $item['author'];
  $this
    ->assertTrue(array_key_exists('name', $author_info), 'JSON Feed item author name attribute present.');
  $this
    ->assertEqual(self::ADMIN_NAME, $author_info['name'], 'JSON Feed item author name set correctly.');
}