You are here

public function LimitOperatorsDefaultsTest::testViewsPostUpdateLimitOperatorsDefaultValues in Drupal 8

Tests that default settings for limit operators are present.

@covers ::needsOperatorDefaultsUpdate

File

core/modules/views/tests/src/Functional/Update/LimitOperatorsDefaultsTest.php, line 35

Class

LimitOperatorsDefaultsTest
Tests the upgrade path for limit operators feature.

Namespace

Drupal\Tests\views\Functional\Update

Code

public function testViewsPostUpdateLimitOperatorsDefaultValues() {

  // Load and initialize our test view.
  $view = View::load('test_exposed_filters');
  $data = $view
    ->toArray();

  // Check that the filters have no defaults values to limit operators.
  $title_filter = $data['display']['default']['display_options']['filters']['title']['expose'];
  $this
    ->assertArrayNotHasKey('operator_limit_selection', $title_filter);
  $this
    ->assertArrayNotHasKey('operator_list', $title_filter);
  $created_filter = $data['display']['default']['display_options']['filters']['created']['expose'];
  $this
    ->assertArrayNotHasKey('operator_limit_selection', $created_filter);
  $this
    ->assertArrayNotHasKey('operator_list', $created_filter);
  $this
    ->runUpdates();

  // Load and initialize our test view.
  $view = View::load('test_exposed_filters');
  $data = $view
    ->toArray();

  // Check that the filters have defaults values to limit operators.
  $title_filter = $data['display']['default']['display_options']['filters']['title']['expose'];
  $this
    ->assertIdentical(FALSE, $title_filter['operator_limit_selection']);
  $this
    ->assertIdentical([], $title_filter['operator_list']);
  $created_filter = $data['display']['default']['display_options']['filters']['created']['expose'];
  $this
    ->assertIdentical(FALSE, $created_filter['operator_limit_selection']);
  $this
    ->assertIdentical([], $created_filter['operator_list']);
}