DefaultFormatTest.php

Same filename and directory in other branches
  1. 9 core/tests/Drupal/FunctionalTests/Routing/DefaultFormatTest.php
  2. 8.9.x core/tests/Drupal/FunctionalTests/Routing/DefaultFormatTest.php
  3. 10 core/tests/Drupal/FunctionalTests/Routing/DefaultFormatTest.php

Namespace

Drupal\FunctionalTests\Routing

File

core/tests/Drupal/FunctionalTests/Routing/DefaultFormatTest.php

View source
<?php

declare (strict_types=1);
namespace Drupal\FunctionalTests\Routing;

use Drupal\Tests\BrowserTestBase;

/**
 * @group routing
 */
class DefaultFormatTest extends BrowserTestBase {
  
  /**
   * {@inheritdoc}
   */
  protected static $modules = [
    'system',
    'default_format_test',
  ];
  
  /**
   * {@inheritdoc}
   */
  protected $defaultTheme = 'stark';
  public function testFoo() : void {
    $this->drupalGet('/default_format_test/human');
    $this->assertSame('format:html', $this->getSession()
      ->getPage()
      ->getContent());
    $this->assertSession()
      ->responseHeaderEquals('X-Drupal-Cache', 'MISS');
    $this->drupalGet('/default_format_test/human');
    $this->assertSame('format:html', $this->getSession()
      ->getPage()
      ->getContent());
    $this->assertSession()
      ->responseHeaderEquals('X-Drupal-Cache', 'HIT');
    $this->drupalGet('/default_format_test/machine');
    $this->assertSame('format:json', $this->getSession()
      ->getPage()
      ->getContent());
    $this->assertSession()
      ->responseHeaderEquals('X-Drupal-Cache', 'MISS');
    $this->drupalGet('/default_format_test/machine');
    $this->assertSame('format:json', $this->getSession()
      ->getPage()
      ->getContent());
    $this->assertSession()
      ->responseHeaderEquals('X-Drupal-Cache', 'HIT');
  }
  public function testMultipleRoutesWithSameSingleFormat() : void {
    $this->drupalGet('/default_format_test/machine');
    $this->assertSame('format:json', $this->getSession()
      ->getPage()
      ->getContent());
  }

}

Classes

Title Deprecated Summary
DefaultFormatTest @group routing

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.