protected function ViewStorageTest::displayTests

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

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

File

drupal/core/modules/views/lib/Drupal/views/Tests/ViewStorageTest.php, line 168
Definition of Drupal\views\Tests\ViewStorageTest.

Class

ViewStorageTest
Tests the functionality of View and ViewStorageController.

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
    ->newDisplay('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
    ->get('executable');
  $executable
    ->initDisplay();
  $this
    ->assertTrue($executable->displayHandlers
    ->get($new_id) instanceof Page, 'New page display "test" uses the right display plugin.');
  $view
    ->set('id', 'test_view_storage_new_new2');
  $view
    ->save();
  $values = config('views.view.test_view_storage_new_new2')
    ->get();
  $this
    ->assertTrue(isset($values['display']['test']) && is_array($values['display']['test']), 'New display was saved.');
}