You are here

public function RowEntityTest::testEntityRow in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/views/src/Tests/Plugin/RowEntityTest.php \Drupal\views\Tests\Plugin\RowEntityTest::testEntityRow()

Tests the entity row handler.

File

core/modules/views/src/Tests/Plugin/RowEntityTest.php, line 50
Contains \Drupal\views\Tests\Plugin\RowEntityTest.

Class

RowEntityTest
Tests the generic entity row plugin.

Namespace

Drupal\views\Tests\Plugin

Code

public function testEntityRow() {
  $vocab = entity_create('taxonomy_vocabulary', array(
    'name' => $this
      ->randomMachineName(),
    'vid' => strtolower($this
      ->randomMachineName()),
  ));
  $vocab
    ->save();
  $term = entity_create('taxonomy_term', array(
    'name' => $this
      ->randomMachineName(),
    'vid' => $vocab
      ->id(),
  ));
  $term
    ->save();
  $view = Views::getView('test_entity_row');
  $build = $view
    ->preview();
  $this
    ->render($build);
  $this
    ->assertText($term
    ->getName(), 'The rendered entity appears as row in the view.');

  // Tests the available view mode options.
  $form = array();
  $form_state = new FormState();
  $form_state
    ->set('view', $view->storage);
  $view->rowPlugin
    ->buildOptionsForm($form, $form_state);
  $this
    ->assertTrue(isset($form['view_mode']['#options']['default']), 'Ensure that the default view mode is available');
}