3 namespace Drupal\Tests\taxonomy\Functional;
5 use Drupal\taxonomy\Entity\Vocabulary;
6 use Drupal\Tests\BrowserTestBase;
9 * Regression test for https://www.drupal.org/node/2807263.
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.
19 class VocabularySerializationTest extends BrowserTestBase {
24 public static $modules = ['taxonomy', 'vocabulary_serialization_test'];
29 public function setUp() {
32 Vocabulary::create(['vid' => 'test'])->save();
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');
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');