view core/tests/Drupal/FunctionalTests/Routing/DefaultFormatTest.php @ 18:af1871eacc83

Update to Drupal core 8.7.1
author Chris Cannam
date Thu, 09 May 2019 15:33:08 +0100
parents c2387f117808
children
line wrap: on
line source
<?php

namespace Drupal\FunctionalTests\Routing;

use Drupal\Tests\BrowserTestBase;

/**
 * @group routing
 */
class DefaultFormatTest extends BrowserTestBase {

  /**
   * {@inheritdoc}
   */
  public static $modules = ['system', 'default_format_test'];

  public function testFoo() {
    $this->drupalGet('/default_format_test/human');
    $this->assertSame('format:html', $this->getSession()->getPage()->getContent());
    $this->assertSame('MISS', $this->drupalGetHeader('X-Drupal-Cache'));
    $this->drupalGet('/default_format_test/human');
    $this->assertSame('format:html', $this->getSession()->getPage()->getContent());
    $this->assertSame('HIT', $this->drupalGetHeader('X-Drupal-Cache'));

    $this->drupalGet('/default_format_test/machine');
    $this->assertSame('format:json', $this->getSession()->getPage()->getContent());
    $this->assertSame('MISS', $this->drupalGetHeader('X-Drupal-Cache'));
    $this->drupalGet('/default_format_test/machine');
    $this->assertSame('format:json', $this->getSession()->getPage()->getContent());
    $this->assertSame('HIT', $this->drupalGetHeader('X-Drupal-Cache'));
  }

  public function testMultipleRoutesWithSameSingleFormat() {
    $this->drupalGet('/default_format_test/machine');
    $this->assertSame('format:json', $this->getSession()->getPage()->getContent());
  }

}