Chris@0: getProtectedFiles() as $file => $response_code) { Chris@0: $this->assertFileAccess($file, $response_code); Chris@0: } Chris@0: Chris@0: // Test that adding "/1" to a .php URL does not make it accessible. Chris@0: $this->drupalGet('core/lib/Drupal.php/1'); Chris@0: $this->assertResponse(403, "Access to core/lib/Drupal.php/1 is denied."); Chris@0: Chris@0: // Test that it is possible to have path aliases containing .php. Chris@0: $type = $this->drupalCreateContentType(); Chris@0: Chris@0: // Create an node aliased to test.php. Chris@0: $node = $this->drupalCreateNode([ Chris@0: 'title' => 'This is a node', Chris@0: 'type' => $type->id(), Chris@0: 'path' => '/test.php' Chris@0: ]); Chris@0: $node->save(); Chris@0: $this->drupalGet('test.php'); Chris@0: $this->assertResponse(200); Chris@0: $this->assertText('This is a node'); Chris@0: Chris@0: // Update node's alias to test.php/test. Chris@0: $node->path = '/test.php/test'; Chris@0: $node->save(); Chris@0: $this->drupalGet('test.php/test'); Chris@0: $this->assertResponse(200); Chris@0: $this->assertText('This is a node'); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Asserts that a file exists and requesting it returns a specific response. Chris@0: * Chris@0: * @param string $path Chris@0: * Path to file. Without leading slash. Chris@0: * @param int $response_code Chris@0: * The expected response code. For example: 200, 403 or 404. Chris@0: * Chris@0: * @return bool Chris@0: * TRUE if the assertion succeeded, FALSE otherwise. Chris@0: */ Chris@0: protected function assertFileAccess($path, $response_code) { Chris@0: $result = $this->assertTrue(file_exists(\Drupal::root() . '/' . $path), "The file $path exists."); Chris@0: $this->drupalGet($path); Chris@0: $result = $result && $this->assertResponse($response_code, "Response code to $path is $response_code."); Chris@0: return $result; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Tests that SVGZ files are served with Content-Encoding: gzip. Chris@0: */ Chris@0: public function testSvgzContentEncoding() { Chris@0: $this->drupalGet('core/modules/system/tests/logo.svgz'); Chris@0: $this->assertResponse(200); Chris@0: $header = $this->drupalGetHeader('Content-Encoding'); Chris@0: $this->assertEqual($header, 'gzip'); Chris@0: } Chris@0: Chris@0: }