comparison core/modules/views/src/Tests/Update/EntityViewsMultiValueBaseFieldDataUpdateTest.php @ 14:1fec387a4317

Update Drupal core to 8.5.2 via Composer
author Chris Cannam
date Mon, 23 Apr 2018 09:46:53 +0100
parents
children
comparison
equal deleted inserted replaced
13:5fb285c0d0e3 14:1fec387a4317
1 <?php
2
3 namespace Drupal\views\Tests\Update;
4
5 use Drupal\system\Tests\Update\UpdatePathTestBase;
6 use Drupal\views\Views;
7
8 /**
9 * Tests the upgrade path for views multi-value base field data.
10 *
11 * @see views_update_8500()
12 *
13 * @group Update
14 */
15 class EntityViewsMultiValueBaseFieldDataUpdateTest extends UpdatePathTestBase {
16
17 /**
18 * {@inheritdoc}
19 */
20 protected function setDatabaseDumpFiles() {
21 $this->databaseDumpFiles = [
22 __DIR__ . '/../../../../system/tests/fixtures/update/drupal-8.bare.standard.php.gz',
23 __DIR__ . '/../../../../system/tests/fixtures/update/drupal-8.views-entity-views-data-2846614.php',
24 ];
25 }
26
27 /**
28 * Tests multi-value base field views data is updated correctly.
29 */
30 public function testUpdateMultiValueBaseFields() {
31 $this->runUpdates();
32
33 $view = Views::getView('test_user_multi_value');
34 $display = $view->storage->get('display');
35
36 // Check each handler type present in the configuration to make sure the
37 // field got updated correctly.
38 foreach (['fields', 'filters', 'arguments'] as $type) {
39 $handler_config = $display['default']['display_options'][$type]['roles'];
40
41 // The ID should remain unchanged. Otherwise the update handler could
42 // overwrite a separate handler config.
43 $this->assertEqual('roles', $handler_config['id']);
44 // The field should be updated from 'roles' to the correct column name.
45 $this->assertEqual('roles_target_id', $handler_config['field']);
46 // Check the table is still correct.
47 $this->assertEqual('user__roles', $handler_config['table']);
48
49 // The plugin ID should be updated as well.
50 $this->assertEqual($type === 'arguments' ? 'user__roles_rid' : 'user_roles', $handler_config['plugin_id']);
51 }
52 }
53
54 }