LimitOperatorsDefaultsTest.php in Drupal 8
File
core/modules/views/tests/src/Functional/Update/LimitOperatorsDefaultsTest.php
View source
<?php
namespace Drupal\Tests\views\Functional\Update;
use Drupal\FunctionalTests\Update\UpdatePathTestBase;
use Drupal\views\Entity\View;
class LimitOperatorsDefaultsTest extends UpdatePathTestBase {
protected function setDatabaseDumpFiles() {
$this->databaseDumpFiles = [
__DIR__ . '/../../../../../system/tests/fixtures/update/drupal-8.bare.standard.php.gz',
__DIR__ . '/../../../fixtures/update/limit-exposed-operators.php',
];
}
public function testViewsPostUpdateLimitOperatorsDefaultValues() {
$view = View::load('test_exposed_filters');
$data = $view
->toArray();
$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();
$view = View::load('test_exposed_filters');
$data = $view
->toArray();
$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']);
}
}