You are here

protected function ViewStorageTest::displayTests in Zircon Profile 8

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

Tests adding, saving, and loading displays on configuration entities.

1 call to ViewStorageTest::displayTests()
ViewStorageTest::testConfigurationEntityCRUD in core/modules/views/src/Tests/ViewStorageTest.php
Tests CRUD operations.

File

core/modules/views/src/Tests/ViewStorageTest.php, line 158
Contains \Drupal\views\Tests\ViewStorageTest.

Class

ViewStorageTest
Tests the CRUD functionality for a view.

Namespace

Drupal\views\Tests

Code

protected function displayTests() {

  // Check whether a display can be added and saved to a View.
  $view = entity_load('view', 'test_view_storage_new');
  $new_id = $view
    ->addDisplay('page', 'Test', 'test');
  $display = $view
    ->get('display');

  // Ensure the right display_plugin is created/instantiated.
  $this
    ->assertEqual($display[$new_id]['display_plugin'], 'page', 'New page display "test" uses the right display plugin.');
  $executable = $view
    ->getExecutable();
  $executable
    ->initDisplay();
  $this
    ->assertTrue($executable->displayHandlers
    ->get($new_id) instanceof Page, 'New page display "test" uses the right display plugin.');

  // To save this with a new ID, we should use createDuplicate().
  $view = $view
    ->createDuplicate();
  $view
    ->set('id', 'test_view_storage_new_new2');
  $view
    ->save();
  $values = $this
    ->config('views.view.test_view_storage_new_new2')
    ->get();
  $this
    ->assertTrue(isset($values['display']['test']) && is_array($values['display']['test']), 'New display was saved.');
}