You are here

public function EntityFieldExportTest::testRenderItems in REST Views 8

Same name and namespace in other branches
  1. 2.0.x tests/src/Unit/EntityFieldExportTest.php \Drupal\Tests\rest_views\Unit\EntityFieldExportTest::testRenderItems()

Check that the handler correctly preserves serializable items.

@dataProvider providerItems

Parameters

array $items: Item data to be rendered.

array $expected: Expected output.

Throws

\Exception

File

tests/src/Unit/EntityFieldExportTest.php, line 154

Class

EntityFieldExportTest
Test the EntityFieldExport views field plugin.

Namespace

Drupal\Tests\rest_views\Unit

Code

public function testRenderItems(array $items, array $expected) {
  $this->handler->multiple = FALSE;
  $result = $this->handler
    ->renderItems($items);
  $json = $this->serializer
    ->serialize($result, 'json');
  $expected_json = $this->serializer
    ->serialize($expected[0], 'json');
  $this
    ->assertEquals($expected_json, $json);
  $this->handler->multiple = TRUE;
  $result = $this->handler
    ->renderItems($items);
  $json = $this->serializer
    ->serialize($result, 'json');
  $expected_json = $this->serializer
    ->serialize($expected, 'json');
  $this
    ->assertEquals($expected_json, $json);
}