DefaultFormatTest.php 918 B

1234567891011121314151617181920212223242526272829303132
  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. public function testFoo() {
  13. $this->drupalGet('/default_format_test/human');
  14. $this->assertSame('format:html', $this->getSession()->getPage()->getContent());
  15. $this->assertSame('MISS', $this->drupalGetHeader('X-Drupal-Cache'));
  16. $this->drupalGet('/default_format_test/machine');
  17. $this->assertSame('format:json', $this->getSession()->getPage()->getContent());
  18. $this->assertSame('MISS', $this->drupalGetHeader('X-Drupal-Cache'));
  19. }
  20. public function testMultipleRoutesWithSameSingleFormat() {
  21. $this->drupalGet('/default_format_test/machine');
  22. $this->assertSame('format:json', $this->getSession()->getPage()->getContent());
  23. }
  24. }