You are here

public function RestfulViewModeAndFormatterTestCase::testViewModeIntegration in RESTful 7

Same name and namespace in other branches
  1. 7.2 tests/RestfulViewModeAndFormatterTestCase.test \RestfulViewModeAndFormatterTestCase::testViewModeIntegration()

Test the view mode integration.

File

tests/RestfulViewModeAndFormatterTestCase.test, line 25
Contains RestfulViewModeFormatterTestCase

Class

RestfulViewModeAndFormatterTestCase
@file Contains RestfulViewModeFormatterTestCase

Code

public function testViewModeIntegration() {
  $handler = restful_get_restful_handler('articles', 1, 7);
  $nodes[] = restful_test_create_node_with_tags();
  $nodes[] = restful_test_create_node_with_tags();

  // Make sure to get more than one node to increase coverage on
  // \RestfulEntityViewMode.
  $result = $handler
    ->get($nodes[0]->nid . ',' . $nodes[1]->nid);

  // Make sure that all the fields were mapped.
  $this
    ->assertNotNull($result[0]['body'], 'Body field is populated.');
  $this
    ->assertTrue($result[0]['tags'], 'Tags field is populated.');
  $this
    ->assertNotNull($result[0]['image'], 'Image field is not NULL.');
}