public function StyleSerializerTest::testFieldRawOutput

Tests the raw output options for row field rendering.

File

drupal/core/modules/rest/lib/Drupal/rest/Tests/Views/StyleSerializerTest.php, line 243
Contains \Drupal\rest\Tests\Views\StyleSerializerTest.

Class

StyleSerializerTest
Tests the serializer style plugin.

Namespace

Drupal\rest\Tests\Views

Code

public function testFieldRawOutput() {
  $this
    ->drupalLogin($this->adminUser);

  // Test the UI settings for adding field ID aliases.
  $this
    ->drupalGet('admin/structure/views/view/test_serializer_display_field/edit/rest_export_1');
  $row_options = 'admin/structure/views/nojs/display/test_serializer_display_field/rest_export_1/row_options';
  $this
    ->assertLinkByHref($row_options);

  // Test an empty string for an alias, this should not be used. This also
  // tests that the form can be submitted with no aliases.
  $this
    ->drupalPost($row_options, array(
    'row_options[field_options][created][raw_output]' => '1',
  ), t('Apply'));
  $this
    ->drupalPost(NULL, array(), t('Save'));
  $view = views_get_view('test_serializer_display_field');
  $view
    ->setDisplay('rest_export_1');
  $this
    ->executeView($view);

  // Just test the raw 'created' value against each row.
  foreach ($this
    ->drupalGetJSON('test/serialize/field') as $index => $values) {
    $this
      ->assertIdentical($values['created'], $view->result[$index]->views_test_data_created, 'Expected raw created value found.');
  }
}