You are here

public function FinderTest::testIgnoredAccessDeniedException in Database Sanitize 7

File

vendor/symfony/finder/Tests/FinderTest.php, line 707

Class

FinderTest

Namespace

Symfony\Component\Finder\Tests

Code

public function testIgnoredAccessDeniedException() {
  if ('\\' === \DIRECTORY_SEPARATOR) {
    $this
      ->markTestSkipped('chmod is not supported on Windows');
  }
  $finder = $this
    ->buildFinder();
  $finder
    ->files()
    ->ignoreUnreadableDirs()
    ->in(self::$tmpDir);

  // make 'foo' directory non-readable
  $testDir = self::$tmpDir . \DIRECTORY_SEPARATOR . 'foo';
  chmod($testDir, 0333);
  if (false === ($couldRead = is_readable($testDir))) {
    $this
      ->assertIterator($this
      ->toAbsolute(array(
      'foo bar',
      'test.php',
      'test.py',
    )), $finder
      ->getIterator());
  }

  // restore original permissions
  chmod($testDir, 0777);
  clearstatcache($testDir);
  if ($couldRead) {
    $this
      ->markTestSkipped('could read test files while test requires unreadable');
  }
}