public function EntityViewsDataUpdateTest::testUpdateHookN in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/views/src/Tests/Update/EntityViewsDataUpdateTest.php \Drupal\views\Tests\Update\EntityViewsDataUpdateTest::testUpdateHookN()
Tests that field plugins are updated properly.
File
- core/
modules/ views/ src/ Tests/ Update/ EntityViewsDataUpdateTest.php, line 35 - Contains \Drupal\views\Tests\Update\EntityViewsDataUpdateTest.
Class
- EntityViewsDataUpdateTest
- Tests the upgrade path for views field plugins.
Namespace
Drupal\views\Tests\UpdateCode
public function testUpdateHookN() {
$this
->runUpdates();
// Load and initialize our test view.
$view = Views::getView('update_test');
$view
->initHandlers();
// Extract the fields from the test view that were updated.
/** @var \Drupal\views\Plugin\views\field\Field $field */
$created = $view->field['created'];
/** @var \Drupal\views\Plugin\views\field\Field $field */
$created_1 = $view->field['created_1'];
/** @var \Drupal\views\Plugin\views\field\Field $field */
$created_2 = $view->field['created_2'];
// Make sure the plugins were converted from date to field.
$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');
// Check options on 'created'.
$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');
// Check options on 'created'.
$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);
// Check options on 'created'.
$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);
}