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 188
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 = $this
    ->loadView('frontpage');
  $view
    ->newDisplay('page', 'Test', 'test');
  $new_display = $view
    ->get('display');

  // Ensure the right display_plugin is created/instantiated.
  $this
    ->assertEqual($new_display['test']['display_plugin'], 'page', 'New page display "test" uses the right display plugin.');
  $this
    ->assertTrue($view
    ->get('executable')->displayHandlers[$new_display['test']['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.');
}