Backup of db before drupal security update
[yaffs-website] / web / core / modules / taxonomy / tests / src / Functional / VocabularySerializationTest.php
1 <?php
2
3 namespace Drupal\Tests\taxonomy\Functional;
4
5 use Drupal\taxonomy\Entity\Vocabulary;
6 use Drupal\Tests\BrowserTestBase;
7
8 /**
9  * Regression test for https://www.drupal.org/node/2807263.
10  *
11  * When a Vocabulary entity is unserialized before the modules have been loaded
12  * (which happens in the KernelPreHandle Stack middleware), then the constants
13  * that the Vocabulary entity uses are not yet available because they are set in
14  * taxonomy.module. This means that for example the PageCache middleware cannot
15  * load any cached Vocabulary entity, because unserialization will fail.
16  *
17  * @group taxonomy
18  */
19 class VocabularySerializationTest extends BrowserTestBase {
20
21   /**
22    * {@inheritdoc}
23    */
24   public static $modules = ['taxonomy', 'vocabulary_serialization_test'];
25
26   /**
27    * {@inheritdoc}
28    */
29   public function setUp() {
30     parent::setUp();
31
32     Vocabulary::create(['vid' => 'test'])->save();
33   }
34
35   public function testSerialization() {
36     $this->drupalGet('/vocabulary_serialization_test/test');
37     $this->assertSession()->statusCodeEquals(200);
38     $this->assertSame('this is the output', $this->getSession()->getPage()->getContent());
39     $this->assertSession()->responseHeaderEquals('X-Drupal-Cache', 'MISS');
40
41     $this->drupalGet('/vocabulary_serialization_test/test');
42     $this->assertSession()->statusCodeEquals(200);
43     $this->assertSame('this is the output', $this->getSession()->getPage()->getContent());
44     $this->assertSession()->responseHeaderEquals('X-Drupal-Cache', 'HIT');
45   }
46
47 }