You are here

protected function ViewStorageTest::displayTests in Views (for Drupal 7) 8.3

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

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

File

lib/Drupal/views/Tests/ViewStorageTest.php, line 243
Definition of Drupal\views\Tests\ViewStorageTest.

Class

ViewStorageTest
Tests the functionality of ViewStorage and ViewStorageController.

Namespace

Drupal\views\Tests

Code

protected function displayTests() {

  // Check whether a display can be added and saved to a View.
  $view = $this
    ->loadView('frontpage');
  $view
    ->newDisplay('page', 'Test', 'test');
  $new_display = $view->display['test'];

  // Ensure the right display_plugin is created/instantiated.
  $this
    ->assertEqual($new_display['display_plugin'], 'page', 'New page display "test" uses the right display plugin.');
  $this
    ->assertTrue($view
    ->getExecutable()->displayHandlers[$new_display['id']] instanceof Page, 'New page display "test" uses the right display plugin.');
  $view
    ->set('name', 'frontpage_new');
  $view
    ->save();
  $values = config('views.view.frontpage_new')
    ->get();
  $this
    ->assertTrue(isset($values['display']['test']) && is_array($values['display']['test']), 'New display was saved.');
}