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