You are here

public function DirectoryIterationTestCase::directoryIteration_Bug_4 in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/DirectoryIterationTestCase.php \org\bovigo\vfs\DirectoryIterationTestCase::directoryIteration_Bug_4()

assure that a directory iteration works as expected

@author Christoph Bloemer

@test @dataProvider provideSwitchWithExpectations @group regression @group bug_4

Parameters

\Closure $dotFilesSwitch:

string[] $expectedDirectories:

File

vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/DirectoryIterationTestCase.php, line 152

Class

DirectoryIterationTestCase
Test for directory iteration.

Namespace

org\bovigo\vfs

Code

public function directoryIteration_Bug_4(\Closure $dotFilesSwitch, array $expectedDirectories) {
  $dotFilesSwitch();
  $dir = $this->fooURL;
  $list1 = array();
  if ($handle = opendir($dir)) {
    while (false !== ($listItem = readdir($handle))) {
      if ('.' != $listItem && '..' != $listItem) {
        if (is_file($dir . '/' . $listItem) === true) {
          $list1[] = 'File:[' . $listItem . ']';
        }
        elseif (is_dir($dir . '/' . $listItem) === true) {
          $list1[] = 'Folder:[' . $listItem . ']';
        }
      }
    }
    closedir($handle);
  }
  $list2 = array();
  if ($handle = opendir($dir)) {
    while (false !== ($listItem = readdir($handle))) {
      if ('.' != $listItem && '..' != $listItem) {
        if (is_file($dir . '/' . $listItem) === true) {
          $list2[] = 'File:[' . $listItem . ']';
        }
        elseif (is_dir($dir . '/' . $listItem) === true) {
          $list2[] = 'Folder:[' . $listItem . ']';
        }
      }
    }
    closedir($handle);
  }
  $this
    ->assertEquals($list1, $list2);
  $this
    ->assertEquals(2, count($list1));
  $this
    ->assertEquals(2, count($list2));
}