DatetimeRangeViewUpdateTest.php in Drupal 8
File
core/modules/datetime_range/tests/src/Functional/Update/DatetimeRangeViewUpdateTest.php
View source
<?php
namespace Drupal\Tests\datetime_range\Functional\Update;
use Drupal\FunctionalTests\Update\UpdatePathTestBase;
use Drupal\views\Entity\View;
class DatetimeRangeViewUpdateTest extends UpdatePathTestBase {
protected function setDatabaseDumpFiles() {
$this->databaseDumpFiles = [
__DIR__ . '/../../../../../system/tests/fixtures/update/drupal-8.bare.standard.php.gz',
__DIR__ . '/../../../../tests/fixtures/update/datetime_range-filter-values.php',
];
}
public function testViewsPostUpdateDateRangeFilterValues() {
$view = View::load('test_datetime_range_filter_values');
$data = $view
->toArray();
$filter1 = $data['display']['default']['display_options']['filters']['field_range_value'];
$this
->assertSame('string', $filter1['plugin_id']);
$filter2 = $data['display']['default']['display_options']['filters']['field_range_end_value'];
$this
->assertSame('string', $filter2['plugin_id']);
$this
->assertSame('', $filter2['value']);
$this
->assertSame('contains', $filter2['operator']);
$sort = $data['display']['default']['display_options']['sorts']['field_range_value'];
$this
->assertSame('standard', $sort['plugin_id']);
$this
->runUpdates();
$view = View::load('test_datetime_range_filter_values');
$data = $view
->toArray();
$filter1 = $data['display']['default']['display_options']['filters']['field_range_value'];
$this
->assertSame('datetime', $filter1['plugin_id']);
$this
->assertSame('2017', $filter1['value']['value']);
$this
->assertSame('=', $filter1['operator']);
$filter2 = $data['display']['default']['display_options']['filters']['field_range_end_value'];
$this
->assertSame('datetime', $filter2['plugin_id']);
$this
->assertSame('.*', $filter2['value']['value']);
$this
->assertSame('regular_expression', $filter2['operator']);
$sort = $data['display']['default']['display_options']['sorts']['field_range_value'];
$this
->assertSame('datetime', $sort['plugin_id']);
}
}