Skip to content

Commit

Permalink
Sort listing before checking visibility.
Browse files Browse the repository at this point in the history
  • Loading branch information
frankdejonge committed Jan 11, 2022
1 parent 21ee228 commit edc152a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Local/LocalFilesystemAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

namespace League\Flysystem\Local;

use function strnatcasecmp;
use function usort;
use const LOCK_EX;
use League\Flysystem\AdapterTestUtilities\FilesystemAdapterTestCase;
use League\Flysystem\Config;
Expand Down Expand Up @@ -302,13 +304,17 @@ public function retrieving_visibility_while_listing_directory_contents(): void

/** @var Traversable<StorageAttributes> $contentListing */
$contentListing = $adapter->listContents('/', true);
$listing = iterator_to_array($contentListing);
usort($listing, function(StorageAttributes $a, StorageAttributes $b) {
return strnatcasecmp($a->path(), $b->path());
});
/**
* @var StorageAttributes $publicDirectoryAttributes
* @var StorageAttributes $privateFileAttributes
* @var StorageAttributes $privateDirectoryAttributes
* @var StorageAttributes $publicFileAttributes
*/
[$publicDirectoryAttributes, $privateFileAttributes, $privateDirectoryAttributes, $publicFileAttributes] = iterator_to_array($contentListing);
[$privateDirectoryAttributes, $publicFileAttributes, $publicDirectoryAttributes, $privateFileAttributes] = $listing;

$this->assertEquals('public', $publicDirectoryAttributes->visibility());
$this->assertEquals('private', $privateFileAttributes->visibility());
Expand Down

0 comments on commit edc152a

Please sign in to comment.