public function Fast404ExtensionTest::testExtensionCheck in Fast 404 8
Same name and namespace in other branches
- 8.2 tests/src/Functional/Fast404ExtensionTest.php \Drupal\Tests\fast404\Functional\Fast404ExtensionTest::testExtensionCheck()
Tests the extension checking functionality.
File
- tests/
src/ Functional/ Fast404ExtensionTest.php, line 29
Class
- Fast404ExtensionTest
- Tests the extension checking functionality.
Namespace
Drupal\Tests\fast404\FunctionalCode
public function testExtensionCheck() {
// Ensure extension check for .doc isn't activated by default.
$this
->drupalGet('/unknowfile.doc');
$this
->assertSession()
->statusCodeEquals(404);
$this
->assertSession()
->pageTextContains('The requested page could not be found.');
// Ensure robots.txt is not blocked by default settings.
$this
->drupalGet('/robots.txt');
$this
->assertSession()
->statusCodeEquals(200);
\Drupal::service('cache.page')
->deleteAll();
// Add .doc to the default extension list.
$settings['settings']['fast404_exts'] = (object) [
'value' => '/^(?!robots).*\\.(txt|png|gif|jpe?g|css|js|ico|swf|flv|cgi|bat|pl|dll|exe|asp|doc)$/i',
'required' => TRUE,
];
$this
->writeSettings($settings);
$this
->drupalGet('/unknowfile.doc');
$this
->assertSession()
->statusCodeEquals(404);
$this
->assertSession()
->pageTextContains('Not Found');
$this
->assertSession()
->responseContains('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>404 Not Found</title></head><body><h1>Not Found</h1><p>The requested URL "/unknowfile.doc" was not found on this server.</p></body></html>');
}