3e40e2b76de165cc64453388de747c371cfdc53e
[yaffs-website] / web / core / modules / views / tests / src / Functional / Update / TableDisplayCacheMaxAgeTest.php
1 <?php
2
3 namespace Drupal\Tests\views\Functional\Update;
4
5 use Drupal\FunctionalTests\Update\UpdatePathTestBase;
6 use Drupal\views\Entity\View;
7
8 /**
9  * Tests the upgrade path for cache max age with table displays.
10  *
11  * @see views_post_update_table_display_cache_max_age()
12  *
13  * @group Update
14  */
15 class TableDisplayCacheMaxAgeTest 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__ . '/../../../fixtures/update/table-cache-max-age.php',
24     ];
25   }
26
27   /**
28    * Tests the upgrade path for cache max age with table displays.
29    */
30   public function testViewsPostUpdateTableDisplayMaxCacheAge() {
31     $view = View::load('test_table_max_age');
32     $data = $view->toArray();
33     $this->assertSame(0, $data['display']['default']['cache_metadata']['max-age']);
34
35     $this->runUpdates();
36
37     // Load and initialize our test view.
38     $view = View::load('test_table_max_age');
39     $data = $view->toArray();
40     // Check that the field is using the expected max age value.
41     $this->assertSame(-1, $data['display']['default']['cache_metadata']['max-age']);
42   }
43
44 }