Skip to content

Commit

Permalink
CI fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
frankdejonge committed Nov 14, 2023
1 parent abc29b9 commit fc4a826
Show file tree
Hide file tree
Showing 24 changed files with 89 additions and 62 deletions.
77 changes: 39 additions & 38 deletions src/AdapterTestUtilities/FilesystemAdapterTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace League\Flysystem\AdapterTestUtilities;

use const PHP_EOL;
use DateInterval;
use DateTimeImmutable;
use Generator;
Expand All @@ -26,7 +27,6 @@
use function file_get_contents;
use function is_resource;
use function iterator_to_array;
use const PHP_EOL;

/**
* @codeCoverageIgnore
Expand Down Expand Up @@ -105,7 +105,7 @@ public function clearStorage(): void
return;
}

$this->runSetup(function() use ($adapter) {
$this->runSetup(function () use ($adapter) {
/** @var StorageAttributes $item */
foreach ($adapter->listContents('', false) as $item) {
if ($item->isDir()) {
Expand All @@ -130,7 +130,7 @@ public function clearCustomAdapter(): void
*/
public function writing_and_reading_with_string(): void
{
$this->runScenario(function() {
$this->runScenario(function () {
$adapter = $this->adapter();

$adapter->write('path.txt', 'contents', new Config());
Expand All @@ -147,7 +147,7 @@ public function writing_and_reading_with_string(): void
*/
public function writing_a_file_with_a_stream(): void
{
$this->runScenario(function() {
$this->runScenario(function () {
$adapter = $this->adapter();
$writeStream = stream_with_contents('contents');

Expand All @@ -165,11 +165,12 @@ public function writing_a_file_with_a_stream(): void

/**
* @test
*
* @dataProvider filenameProvider
*/
public function writing_and_reading_files_with_special_path(string $path): void
{
$this->runScenario(function() use ($path) {
$this->runScenario(function () use ($path) {
$adapter = $this->adapter();

$adapter->write($path, 'contents', new Config());
Expand Down Expand Up @@ -202,7 +203,7 @@ public static function filenameProvider(): Generator
*/
public function writing_a_file_with_an_empty_stream(): void
{
$this->runScenario(function() {
$this->runScenario(function () {
$adapter = $this->adapter();
$writeStream = stream_with_contents('');

Expand All @@ -228,7 +229,7 @@ public function reading_a_file(): void
{
$this->givenWeHaveAnExistingFile('path.txt', 'contents');

$this->runScenario(function() {
$this->runScenario(function () {
$contents = $this->adapter()->read('path.txt');

$this->assertEquals('contents', $contents);
Expand All @@ -242,7 +243,7 @@ public function reading_a_file_with_a_stream(): void
{
$this->givenWeHaveAnExistingFile('path.txt', 'contents');

$this->runScenario(function() {
$this->runScenario(function () {
$readStream = $this->adapter()->readStream('path.txt');
$contents = stream_get_contents($readStream);

Expand All @@ -257,7 +258,7 @@ public function reading_a_file_with_a_stream(): void
*/
public function overwriting_a_file(): void
{
$this->runScenario(function() {
$this->runScenario(function () {
$this->givenWeHaveAnExistingFile('path.txt', 'contents', ['visibility' => Visibility::PUBLIC]);
$adapter = $this->adapter();

Expand All @@ -275,7 +276,7 @@ public function overwriting_a_file(): void
*/
public function a_file_exists_only_when_it_is_written_and_not_deleted(): void
{
$this->runScenario(function() {
$this->runScenario(function () {
$adapter = $this->adapter();

// does not exist before creation
Expand All @@ -296,7 +297,7 @@ public function a_file_exists_only_when_it_is_written_and_not_deleted(): void
*/
public function listing_contents_shallow(): void
{
$this->runScenario(function() {
$this->runScenario(function () {
$this->givenWeHaveAnExistingFile('some/0-path.txt', 'contents');
$this->givenWeHaveAnExistingFile('some/1-nested/path.txt', 'contents');

Expand Down Expand Up @@ -324,7 +325,7 @@ public function listing_contents_shallow(): void
*/
public function checking_if_a_non_existing_directory_exists(): void
{
$this->runScenario(function() {
$this->runScenario(function () {
$adapter = $this->adapter();
self::assertFalse($adapter->directoryExists('this-does-not-exist.php'));
});
Expand All @@ -335,7 +336,7 @@ public function checking_if_a_non_existing_directory_exists(): void
*/
public function checking_if_a_directory_exists_after_writing_a_file(): void
{
$this->runScenario(function() {
$this->runScenario(function () {
$adapter = $this->adapter();
$this->givenWeHaveAnExistingFile('existing-directory/file.txt');
self::assertTrue($adapter->directoryExists('existing-directory'));
Expand All @@ -347,7 +348,7 @@ public function checking_if_a_directory_exists_after_writing_a_file(): void
*/
public function checking_if_a_directory_exists_after_creating_it(): void
{
$this->runScenario(function() {
$this->runScenario(function () {
$adapter = $this->adapter();
$adapter->createDirectory('explicitly-created-directory', new Config());
self::assertTrue($adapter->directoryExists('explicitly-created-directory'));
Expand All @@ -363,7 +364,7 @@ public function checking_if_a_directory_exists_after_creating_it(): void
*/
public function listing_contents_recursive(): void
{
$this->runScenario(function() {
$this->runScenario(function () {
$adapter = $this->adapter();
$adapter->createDirectory('path', new Config());
$adapter->write('path/file.txt', 'string', new Config());
Expand All @@ -389,7 +390,7 @@ protected function formatIncorrectListingCount(array $items): string

protected function givenWeHaveAnExistingFile(string $path, string $contents = 'contents', array $config = []): void
{
$this->runSetup(function() use ($path, $contents, $config) {
$this->runSetup(function () use ($path, $contents, $config) {
$this->adapter()->write($path, $contents, new Config($config));
});
}
Expand All @@ -402,7 +403,7 @@ public function fetching_file_size(): void
$adapter = $this->adapter();
$this->givenWeHaveAnExistingFile('path.txt', 'contents');

$this->runScenario(function() use ($adapter) {
$this->runScenario(function () use ($adapter) {
$attributes = $adapter->fileSize('path.txt');
$this->assertInstanceOf(FileAttributes::class, $attributes);
$this->assertEquals(8, $attributes->fileSize());
Expand All @@ -414,7 +415,7 @@ public function fetching_file_size(): void
*/
public function setting_visibility(): void
{
$this->runScenario(function() {
$this->runScenario(function () {
$adapter = $this->adapter();
$this->givenWeHaveAnExistingFile('path.txt', 'contents', [Config::OPTION_VISIBILITY => Visibility::PUBLIC]);

Expand All @@ -439,7 +440,7 @@ public function fetching_file_size_of_a_directory(): void

$adapter = $this->adapter();

$this->runScenario(function() use ($adapter) {
$this->runScenario(function () use ($adapter) {
$adapter->createDirectory('path', new Config());
$adapter->fileSize('path/');
});
Expand All @@ -452,7 +453,7 @@ public function fetching_file_size_of_non_existing_file(): void
{
$this->expectException(UnableToRetrieveMetadata::class);

$this->runScenario(function() {
$this->runScenario(function () {
$this->adapter()->fileSize('non-existing-file.txt');
});
}
Expand All @@ -464,7 +465,7 @@ public function fetching_last_modified_of_non_existing_file(): void
{
$this->expectException(UnableToRetrieveMetadata::class);

$this->runScenario(function() {
$this->runScenario(function () {
$this->adapter()->lastModified('non-existing-file.txt');
});
}
Expand All @@ -476,7 +477,7 @@ public function fetching_visibility_of_non_existing_file(): void
{
$this->expectException(UnableToRetrieveMetadata::class);

$this->runScenario(function() {
$this->runScenario(function () {
$this->adapter()->visibility('non-existing-file.txt');
});
}
Expand All @@ -486,7 +487,7 @@ public function fetching_visibility_of_non_existing_file(): void
*/
public function fetching_the_mime_type_of_an_svg_file(): void
{
$this->runScenario(function() {
$this->runScenario(function () {
$this->givenWeHaveAnExistingFile('file.svg', file_get_contents(__DIR__ . '/test_files/flysystem.svg'));

$mimetype = $this->adapter()->mimeType('file.svg')->mimeType();
Expand All @@ -502,7 +503,7 @@ public function fetching_mime_type_of_non_existing_file(): void
{
$this->expectException(UnableToRetrieveMetadata::class);

$this->runScenario(function() {
$this->runScenario(function () {
$this->adapter()->mimeType('non-existing-file.txt');
});
}
Expand All @@ -519,7 +520,7 @@ public function fetching_unknown_mime_type_of_a_file(): void

$this->expectException(UnableToRetrieveMetadata::class);

$this->runScenario(function() {
$this->runScenario(function () {
$this->adapter()->mimeType('unknown-mime-type.md5');
});
}
Expand All @@ -532,7 +533,7 @@ public function listing_a_toplevel_directory(): void
$this->givenWeHaveAnExistingFile('path1.txt');
$this->givenWeHaveAnExistingFile('path2.txt');

$this->runScenario(function() {
$this->runScenario(function () {
$contents = iterator_to_array($this->adapter()->listContents('', true));

$this->assertCount(2, $contents);
Expand All @@ -544,7 +545,7 @@ public function listing_a_toplevel_directory(): void
*/
public function writing_and_reading_with_streams(): void
{
$this->runScenario(function() {
$this->runScenario(function () {
$writeStream = stream_with_contents('contents');
$adapter = $this->adapter();

Expand All @@ -568,7 +569,7 @@ public function setting_visibility_on_a_file_that_does_not_exist(): void
{
$this->expectException(UnableToSetVisibility::class);

$this->runScenario(function() {
$this->runScenario(function () {
$this->adapter()->setVisibility('this-path-does-not-exists.txt', Visibility::PRIVATE);
});
}
Expand All @@ -578,7 +579,7 @@ public function setting_visibility_on_a_file_that_does_not_exist(): void
*/
public function copying_a_file(): void
{
$this->runScenario(function() {
$this->runScenario(function () {
$adapter = $this->adapter();
$adapter->write(
'source.txt',
Expand All @@ -600,7 +601,7 @@ public function copying_a_file(): void
*/
public function copying_a_file_again(): void
{
$this->runScenario(function() {
$this->runScenario(function () {
$adapter = $this->adapter();
$adapter->write(
'source.txt',
Expand All @@ -622,7 +623,7 @@ public function copying_a_file_again(): void
*/
public function moving_a_file(): void
{
$this->runScenario(function() {
$this->runScenario(function () {
$adapter = $this->adapter();
$adapter->write(
'source.txt',
Expand Down Expand Up @@ -650,7 +651,7 @@ public function reading_a_file_that_does_not_exist(): void
{
$this->expectException(UnableToReadFile::class);

$this->runScenario(function() {
$this->runScenario(function () {
$this->adapter()->read('path.txt');
});
}
Expand All @@ -662,7 +663,7 @@ public function moving_a_file_that_does_not_exist(): void
{
$this->expectException(UnableToMoveFile::class);

$this->runScenario(function() {
$this->runScenario(function () {
$this->adapter()->move('source.txt', 'destination.txt', new Config());
});
}
Expand All @@ -685,7 +686,7 @@ public function trying_to_delete_a_non_existing_file(): void
*/
public function checking_if_files_exist(): void
{
$this->runScenario(function() {
$this->runScenario(function () {
$adapter = $this->adapter();
$fileExistsBefore = $adapter->fileExists('some/path.txt');
$adapter->write('some/path.txt', 'contents', new Config());
Expand All @@ -701,7 +702,7 @@ public function checking_if_files_exist(): void
*/
public function fetching_last_modified(): void
{
$this->runScenario(function() {
$this->runScenario(function () {
$adapter = $this->adapter();
$adapter->write('path.txt', 'contents', new Config());

Expand Down Expand Up @@ -739,7 +740,7 @@ public function failing_to_read_a_non_existing_file(): void
*/
public function creating_a_directory(): void
{
$this->runScenario(function() {
$this->runScenario(function () {
$adapter = $this->adapter();

$adapter->createDirectory('creating_a_directory/path', new Config());
Expand All @@ -762,7 +763,7 @@ public function creating_a_directory(): void
*/
public function copying_a_file_with_collision(): void
{
$this->runScenario(function() {
$this->runScenario(function () {
$adapter = $this->adapter();
$adapter->write('path.txt', 'new contents', new Config());
$adapter->write('new-path.txt', 'contents', new Config());
Expand All @@ -776,7 +777,7 @@ public function copying_a_file_with_collision(): void

protected function assertFileExistsAtPath(string $path): void
{
$this->runScenario(function() use ($path) {
$this->runScenario(function () use ($path) {
$fileExists = $this->adapter()->fileExists($path);
$this->assertTrue($fileExists);
});
Expand Down
3 changes: 1 addition & 2 deletions src/AsyncAwsS3/AsyncAwsS3AdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,6 @@ private static function s3Client(): S3Client
return static::$s3Client;
}



/**
* @test
*/
Expand Down Expand Up @@ -219,6 +217,7 @@ public function fetching_unknown_mime_type_of_a_file(): void

/**
* @test
*
* @dataProvider dpFailingMetadataGetters
*/
public function failing_to_retrieve_metadata(Exception $exception, string $getterName): void
Expand Down
2 changes: 1 addition & 1 deletion src/AwsS3V3/AwsS3V3Adapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ public function temporaryUrl(string $path, DateTimeInterface $expiresAt, Config
$presignedRequestOptions = $config->get('presigned_request_options', []);
$request = $this->client->createPresignedRequest($command, $expiresAt, $presignedRequestOptions);

return (string)$request->getUri();
return (string) $request->getUri();
} catch (Throwable $exception) {
throw UnableToGenerateTemporaryUrl::dueToError($path, $exception);
}
Expand Down
Loading

0 comments on commit fc4a826

Please sign in to comment.