outline-8.x-1.x-dev/tests/src/Functional/OutlineSerializationTest.php

tests/src/Functional/OutlineSerializationTest.php
<?php

namespace Drupal\Tests\outline\Functional;

use Drupal\outline\Entity\Outline;
use Drupal\Tests\BrowserTestBase;

/**
 * Regression test for https://www.drupal.org/node/2807263.
 *
 * When a Outline entity is unserialized before the modules have been loaded
 * (which happens in the KernelPreHandle Stack middleware), then the constants
 * that the Outline entity uses are not yet available because they are set in
 * outline.module. This means that for example the PageCache middleware cannot
 * load any cached Outline entity, because unserialization will fail.
 *
 * @group outline
 */
class OutlineSerializationTest extends BrowserTestBase {

  /**
   * {@inheritdoc}
   */
  protected static $modules = ['outline', 'outline_serialization_test'];

  /**
   * {@inheritdoc}
   */
  protected $defaultTheme = 'stark';

  /**
   * {@inheritdoc}
   */
  public function setUp(): void {
    parent::setUp();

    Outline::create(['oid' => 'test'])->save();
  }

  public function testSerialization() {
    $this->drupalGet('/outline_serialization_test/test');
    $this->assertSession()->statusCodeEquals(200);
    $this->assertSame('this is the output', $this->getSession()->getPage()->getContent());
    $this->assertSession()->responseHeaderEquals('X-Drupal-Cache', 'MISS');

    $this->drupalGet('/outline_serialization_test/test');
    $this->assertSession()->statusCodeEquals(200);
    $this->assertSame('this is the output', $this->getSession()->getPage()->getContent());
    $this->assertSession()->responseHeaderEquals('X-Drupal-Cache', 'HIT');
  }

}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc