DefaultFormatTest.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. namespace Drupal\FunctionalTests\Routing;
  3. use Drupal\Tests\BrowserTestBase;
  4. /**
  5. * @group routing
  6. */
  7. class DefaultFormatTest extends BrowserTestBase {
  8. /**
  9. * {@inheritdoc}
  10. */
  11. public static $modules = ['system', 'default_format_test'];
  12. /**
  13. * {@inheritdoc}
  14. */
  15. protected $defaultTheme = 'stark';
  16. public function testFoo() {
  17. $this->drupalGet('/default_format_test/human');
  18. $this->assertSame('format:html', $this->getSession()->getPage()->getContent());
  19. $this->assertSame('MISS', $this->drupalGetHeader('X-Drupal-Cache'));
  20. $this->drupalGet('/default_format_test/human');
  21. $this->assertSame('format:html', $this->getSession()->getPage()->getContent());
  22. $this->assertSame('HIT', $this->drupalGetHeader('X-Drupal-Cache'));
  23. $this->drupalGet('/default_format_test/machine');
  24. $this->assertSame('format:json', $this->getSession()->getPage()->getContent());
  25. $this->assertSame('MISS', $this->drupalGetHeader('X-Drupal-Cache'));
  26. $this->drupalGet('/default_format_test/machine');
  27. $this->assertSame('format:json', $this->getSession()->getPage()->getContent());
  28. $this->assertSame('HIT', $this->drupalGetHeader('X-Drupal-Cache'));
  29. }
  30. public function testMultipleRoutesWithSameSingleFormat() {
  31. $this->drupalGet('/default_format_test/machine');
  32. $this->assertSame('format:json', $this->getSession()->getPage()->getContent());
  33. }
  34. }