Pull merge.
[yaffs-website] / web / core / modules / views / tests / src / Functional / Update / EntityViewsMultiValueBaseFieldDataUpdateTest.php
1 <?php
2
3 namespace Drupal\Tests\views\Functional\Update;
4
5 use Drupal\FunctionalTests\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 legacy
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 }