You are here

public function MimeTypeTest::testGuessWithNonReadablePath in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/symfony/http-foundation/Tests/File/MimeType/MimeTypeTest.php \Symfony\Component\HttpFoundation\Tests\File\MimeType\MimeTypeTest::testGuessWithNonReadablePath()

File

vendor/symfony/http-foundation/Tests/File/MimeType/MimeTypeTest.php, line 59

Class

MimeTypeTest
@requires extension fileinfo

Namespace

Symfony\Component\HttpFoundation\Tests\File\MimeType

Code

public function testGuessWithNonReadablePath() {
  if ('\\' === DIRECTORY_SEPARATOR) {
    $this
      ->markTestSkipped('Can not verify chmod operations on Windows');
  }
  if (!getenv('USER') || 'root' === getenv('USER')) {
    $this
      ->markTestSkipped('This test will fail if run under superuser');
  }
  $path = __DIR__ . '/../Fixtures/to_delete';
  touch($path);
  @chmod($path, 0333);
  if (substr(sprintf('%o', fileperms($path)), -4) == '0333') {
    $this
      ->setExpectedException('Symfony\\Component\\HttpFoundation\\File\\Exception\\AccessDeniedException');
    MimeTypeGuesser::getInstance()
      ->guess($path);
  }
  else {
    $this
      ->markTestSkipped('Can not verify chmod operations, change of file permissions failed');
  }
}