View source
<?php
namespace Drupal\views\Tests\Update;
use Drupal\system\Tests\Update\UpdatePathTestBase;
use Drupal\views\Views;
class EntityViewsDataUpdateTest extends UpdatePathTestBase {
protected function setDatabaseDumpFiles() {
$this->databaseDumpFiles = [
__DIR__ . '/../../../../system/tests/fixtures/update/drupal-8.bare.standard.php.gz',
__DIR__ . '/../../../../system/tests/fixtures/update/drupal-8.views-entity-views-data-2455125.php',
];
}
public function testUpdateHookN() {
$this
->runUpdates();
$view = Views::getView('update_test');
$view
->initHandlers();
$created = $view->field['created'];
$created_1 = $view->field['created_1'];
$created_2 = $view->field['created_2'];
$this
->assertEqual($created
->getPluginId(), 'field', 'created has correct plugin_id');
$this
->assertEqual($created_1
->getPluginId(), 'field', 'created has correct plugin_id');
$this
->assertEqual($created_2
->getPluginId(), 'field', 'created has correct plugin_id');
$options = $created->options;
$this
->assertEqual($options['type'], 'timestamp');
$this
->assertFalse(array_key_exists('date_format', $options));
$this
->assertFalse(array_key_exists('custom_date_format', $options));
$this
->assertFalse(array_key_exists('timezone', $options));
$this
->assertEqual($options['settings']['date_format'], 'long');
$this
->assertEqual($options['settings']['custom_date_format'], '');
$this
->assertEqual($options['settings']['timezone'], 'Africa/Abidjan');
$options = $created_1->options;
$this
->assertEqual($options['type'], 'timestamp_ago');
$this
->assertFalse(array_key_exists('date_format', $options));
$this
->assertFalse(array_key_exists('custom_date_format', $options));
$this
->assertFalse(array_key_exists('timezone', $options));
$this
->assertEqual($options['settings']['future_format'], '@interval');
$this
->assertEqual($options['settings']['past_format'], '@interval');
$this
->assertEqual($options['settings']['granularity'], 2);
$options = $created_2->options;
$this
->assertEqual($options['type'], 'timestamp_ago');
$this
->assertFalse(array_key_exists('date_format', $options));
$this
->assertFalse(array_key_exists('custom_date_format', $options));
$this
->assertFalse(array_key_exists('timezone', $options));
$this
->assertEqual($options['settings']['future_format'], '@interval hence');
$this
->assertEqual($options['settings']['past_format'], '@interval ago');
$this
->assertEqual($options['settings']['granularity'], 2);
}
}