protected function ViewStorageTest::loadTests

Tests loading configuration entities.

1 call to ViewStorageTest::loadTests()
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 96
Definition of Drupal\views\Tests\ViewStorageTest.

Class

ViewStorageTest
Tests the functionality of View and ViewStorageController.

Namespace

Drupal\views\Tests

Code

protected function loadTests() {
  $view = entity_load('view', 'test_view_storage');
  $data = config('views.view.test_view_storage')
    ->get();

  // Confirm that an actual view object is loaded and that it returns all of
  // expected properties.
  $this
    ->assertTrue($view instanceof View, 'Single View instance loaded.');
  foreach ($this->config_properties as $property) {
    $this
      ->assertTrue($view
      ->get($property) !== NULL, format_string('Property: @property loaded onto View.', array(
      '@property' => $property,
    )));
  }

  // Check the displays have been loaded correctly from config display data.
  $expected_displays = array(
    'default',
    'page_1',
    'block_1',
  );
  $this
    ->assertEqual(array_keys($view
    ->get('display')), $expected_displays, 'The correct display names are present.');

  // Check each ViewDisplay object and confirm that it has the correct key and
  // property values.
  foreach ($view
    ->get('display') as $key => $display) {
    $this
      ->assertEqual($key, $display['id'], 'The display has the correct ID assigned.');

    // Get original display data and confirm that the display options array
    // exists.
    $original_options = $data['display'][$key];
    foreach ($original_options as $orig_key => $value) {
      $this
        ->assertIdentical($display[$orig_key], $value, format_string('@key is identical to saved data', array(
        '@key' => $key,
      )));
    }
  }

  // Make sure that loaded default views get a UUID.
  $view = views_get_view('test_view_storage');
  $this
    ->assertTrue($view->storage
    ->uuid());
}