class DefaultFormatTest

Same name and namespace in other branches
  1. 11.x core/tests/Drupal/FunctionalTests/Routing/DefaultFormatTest.php \Drupal\FunctionalTests\Routing\DefaultFormatTest
  2. 10 core/tests/Drupal/FunctionalTests/Routing/DefaultFormatTest.php \Drupal\FunctionalTests\Routing\DefaultFormatTest
  3. 8.9.x core/tests/Drupal/FunctionalTests/Routing/DefaultFormatTest.php \Drupal\FunctionalTests\Routing\DefaultFormatTest

@group routing

Hierarchy

Expanded class hierarchy of DefaultFormatTest

File

core/tests/Drupal/FunctionalTests/Routing/DefaultFormatTest.php, line 10

Namespace

Drupal\FunctionalTests\Routing
View source
class DefaultFormatTest extends BrowserTestBase {
  
  /**
   * {@inheritdoc}
   */
  protected static $modules = [
    'system',
    'default_format_test',
  ];
  
  /**
   * {@inheritdoc}
   */
  protected $defaultTheme = 'stark';
  public function testFoo() {
    $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() {
    $this->drupalGet('/default_format_test/machine');
    $this->assertSame('format:json', $this->getSession()
      ->getPage()
      ->getContent());
  }

}

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