class ContentNegotiationTest
Same name in this branch
- 11.x core/modules/system/tests/src/Functional/DrupalKernel/ContentNegotiationTest.php \Drupal\Tests\system\Functional\DrupalKernel\ContentNegotiationTest
Same name and namespace in other branches
- 10 core/modules/system/tests/src/Functional/DrupalKernel/ContentNegotiationTest.php \Drupal\Tests\system\Functional\DrupalKernel\ContentNegotiationTest
- 9 core/modules/system/tests/src/Functional/DrupalKernel/ContentNegotiationTest.php \Drupal\Tests\system\Functional\DrupalKernel\ContentNegotiationTest
- 8.9.x core/modules/system/tests/src/Functional/DrupalKernel/ContentNegotiationTest.php \Drupal\Tests\system\Functional\DrupalKernel\ContentNegotiationTest
- main core/modules/system/tests/src/Functional/DrupalKernel/ContentNegotiationTest.php \Drupal\Tests\system\Functional\DrupalKernel\ContentNegotiationTest
- main core/modules/system/tests/src/Kernel/DrupalKernel/ContentNegotiationTest.php \Drupal\Tests\system\Kernel\DrupalKernel\ContentNegotiationTest
Tests content negotiation.
Attributes
#[Group('DrupalKernel')]
#[RunTestsInSeparateProcesses]
Hierarchy
- class \Drupal\KernelTests\KernelTestBase implements \Drupal\Core\DependencyInjection\ServiceProviderInterface uses \Drupal\Tests\DrupalTestCaseTrait, \Drupal\KernelTests\AssertContentTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\ExtensionListTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\PhpUnitCompatibilityTrait, \Prophecy\PhpUnit\ProphecyTrait, \Drupal\TestTools\Extension\DeprecationBridge\ExpectDeprecationTrait, \Drupal\Tests\BrowserHtmlDebugTrait, \Drupal\Tests\HttpKernelUiHelperTrait extends \PHPUnit\Framework\TestCase
- class \Drupal\Tests\system\Kernel\DrupalKernel\ContentNegotiationTest extends \Drupal\KernelTests\KernelTestBase
Expanded class hierarchy of ContentNegotiationTest
File
-
core/
modules/ system/ tests/ src/ Kernel/ DrupalKernel/ ContentNegotiationTest.php, line 15
Namespace
Drupal\Tests\system\Kernel\DrupalKernelView source
class ContentNegotiationTest extends KernelTestBase {
/**
* {@inheritdoc}
*/
protected static $modules = [
'system',
'user',
];
/**
* {@inheritdoc}
*/
protected function setUp() : void {
parent::setUp();
$this->installConfig([
'system',
]);
}
/**
* Verifies HTML responses for bogus Accept headers.
*
* Drupal does not fully support older browsers, but a page output is still
* expected.
*
* @see https://www.drupal.org/node/1716790
*/
public function testBogusAcceptHeader() : void {
$tests = [
// See https://bugs.webkit.org/show_bug.cgi?id=27267.
'Firefox 3.5 (2009)' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'IE8 (2009)' => 'image/gif, image/jpeg, image/pjpeg, image/pjpeg, application/x-shockwave-flash, application/xaml+xml, application/vnd.ms-xpsdocument, application/x-ms-xbap, application/x-ms-application, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, application/x-silverlight, */*',
'Opera (2009)' => 'text/html, application/xml;q=0.9, application/xhtml+xml, image/png, image/jpeg, image/gif, image/x-xbitmap, */*;q=0.1',
'Chrome (2009)' => 'application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5',
// See https://github.com/symfony/symfony/pull/564.
'Firefox 3.6 (2010)' => 'text/html,application/xhtml+xml,application/json,application/xml;q=0.9,*/*;q=0.8',
'Safari (2010)' => '*/*',
'Opera (2010)' => 'image/jpeg,image/gif,image/x-xbitmap,text/html,image/webp,image/png,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.1',
// See https://www.drupal.org/node/1716790.
'Safari (2010), iOS 4.2.1 (2012)' => 'application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5',
'Android #1 (2012)' => 'application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5',
'Android #2 (2012)' => 'text/xml,text/html,application/xhtml+xml,image/png,text/plain,*/*;q=0.8',
];
foreach ($tests as $header) {
$this->drupalGet('', [], [
'Accept' => $header,
]);
$this->assertSession()
->pageTextNotContains('Unsupported Media Type');
$this->assertSession()
->pageTextContains('Log in');
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.