Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add phpunit v10.x support #1692

Merged
merged 1 commit into from
Aug 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"ext-fileinfo": "*",
"ext-ftp": "*",
"microsoft/azure-storage-blob": "^1.1",
"phpunit/phpunit": "^9.5.11",
"phpunit/phpunit": "^9.5.11|^10.0",
"phpstan/phpstan": "^0.12.26",
"phpseclib/phpseclib": "^3.0.14",
"aws/aws-sdk-php": "^3.220.0",
Expand All @@ -40,7 +40,7 @@
"conflict": {
"async-aws/core": "<1.19.0",
"async-aws/s3": "<1.14.0",
"symfony/http-client": "<6.3.1",
"symfony/http-client": "<5.2",
"guzzlehttp/ringphp": "<1.1.1",
"guzzlehttp/guzzle": "<7.0",
"aws/aws-sdk-php": "3.209.31 || 3.210.0",
Expand Down
13 changes: 5 additions & 8 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,14 @@
<php>
<env name="FLYSYSTEM_TEST_SFTP" value="yes" />
</php>
<filter>
<whitelist>
<directory>src/</directory>
<exclude>
<directory suffix="Test.php">src/</directory>
</exclude>
</whitelist>
</filter>
<groups>
<exclude>
<group>legacy</group>
</exclude>
</groups>
<coverage>
<include>
<directory suffix=".php">src</directory>
</include>
</coverage>
</phpunit>
2 changes: 1 addition & 1 deletion src/AdapterTestUtilities/FilesystemAdapterTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public function writing_and_reading_files_with_special_path(string $path): void
});
}

public function filenameProvider(): Generator
public static function filenameProvider(): Generator
{
yield "a path with square brackets in filename 1" => ["some/file[name].txt"];
yield "a path with square brackets in filename 2" => ["some/file[0].txt"];
Expand Down
2 changes: 1 addition & 1 deletion src/AsyncAwsS3/AsyncAwsS3AdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ public function failing_to_retrieve_metadata(Exception $exception, string $gette
$adapter->{$getterName}('filename.txt');
}

public function dpFailingMetadataGetters(): iterable
public static function dpFailingMetadataGetters(): iterable
{
yield "mimeType" => [UnableToRetrieveMetadata::mimeType('filename.txt'), 'mimeType'];
yield "lastModified" => [UnableToRetrieveMetadata::lastModified('filename.txt'), 'lastModified'];
Expand Down
4 changes: 2 additions & 2 deletions src/AwsS3V3/AwsS3V3AdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ public function failing_to_retrieve_metadata(Exception $exception, string $gette
$adapter->{$getterName}('filename.txt');
}

public function dpFailingMetadataGetters(): iterable
public static function dpFailingMetadataGetters(): iterable
{
yield "mimeType" => [UnableToRetrieveMetadata::mimeType('filename.txt'), 'mimeType'];
yield "lastModified" => [UnableToRetrieveMetadata::lastModified('filename.txt'), 'lastModified'];
Expand Down Expand Up @@ -282,7 +282,7 @@ public function streaming_reads_are_not_seekable_and_non_streaming_are(bool $str
$this->assertEquals($seekable, $metadata['seekable']);
}

public function casesWhereHttpStreamingInfluencesSeekability(): Generator
public static function casesWhereHttpStreamingInfluencesSeekability(): Generator
{
yield "not streaming reads have seekable stream" => [false, true];
yield "streaming reads have non-seekable stream" => [true, false];
Expand Down
2 changes: 1 addition & 1 deletion src/FileAttributesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public function json_transformations(FileAttributes $attributes): void
$this->assertEquals($attributes, $newAttributes);
}

public function data_provider_for_json_transformation(): Generator
public static function data_provider_for_json_transformation(): Generator
{
yield [new FileAttributes('path.txt', 1234, Visibility::PRIVATE, $now = time(), 'plain/text', ['key' => 'value'])];
yield [new FileAttributes('another.txt')];
Expand Down
4 changes: 2 additions & 2 deletions src/FilesystemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function trying_to_write_with_an_invalid_stream_arguments($input): void
$this->filesystem->writeStream('path.txt', $input);
}

public function invalidStreamInput(): Generator
public static function invalidStreamInput(): Generator
{
$handle = tmpfile();
fclose($handle);
Expand Down Expand Up @@ -308,7 +308,7 @@ public function protecting_against_path_traversals(callable $scenario): void
$scenario($this->filesystem);
}

public function scenariosCausingPathTraversal(): Generator
public static function scenariosCausingPathTraversal(): Generator
{
yield [function (FilesystemOperator $filesystem) {
$filesystem->delete('../path.txt');
Expand Down
2 changes: 1 addition & 1 deletion src/Ftp/FtpAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ public function setVisibility(string $path, string $visibility): void
$mode = $this->visibilityConverter->forFile($visibility);

if ( ! @ftp_chmod($this->connection(), $mode, $location)) {
$message = error_get_last()['message'];
$message = error_get_last()['message'] ?? '';
throw UnableToSetVisibility::atLocation($path, $message);
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/Ftp/FtpAdapterTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public function failing_to_write_a_file(callable $scenario): void
});
}

public function scenariosCausingWriteFailure(): Generator
public static function scenariosCausingWriteFailure(): Generator
{
yield "Not being able to create the parent directory" => [function () {
mock_function('ftp_mkdir', false);
Expand Down Expand Up @@ -153,7 +153,7 @@ public function scenarios_causing_directory_deletion_to_fail(callable $scenario)
});
}

public function scenariosCausingDirectoryDeleteFailure(): Generator
public static function scenariosCausingDirectoryDeleteFailure(): Generator
{
yield "ftp_delete failure" => [function () {
mock_function('ftp_delete', false);
Expand Down Expand Up @@ -195,7 +195,7 @@ public function failing_to_move_because_creating_the_directory_fails(): void
});
}

public function scenariosCausingCopyFailure(): Generator
public static function scenariosCausingCopyFailure(): Generator
{
yield "failing to read" => [function () {
mock_function('ftp_fget', false);
Expand Down
20 changes: 0 additions & 20 deletions src/Local/LocalFilesystemAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -724,16 +724,6 @@ protected static function createFilesystemAdapter(): FilesystemAdapter
return new LocalFilesystemAdapter(static::ROOT);
}

public static function assertFileDoesNotExist(string $filename, string $message = ''): void
{
if (is_callable('parent::assertFileDoesNotExist')) {
// PHPUnit 9+
parent::assertFileDoesNotExist($filename, $message);
} else {
self::assertFileNotExists($filename, $message);
}
}

/**
* @test
*/
Expand All @@ -747,14 +737,4 @@ public function get_checksum_with_specified_algo(): void

$this->assertSame('0d5f5c7f', $checksum);
}

public static function assertDirectoryDoesNotExist(string $directory, string $message = ''): void
{
if (is_callable('parent::assertDirectoryDoesNotExist')) {
// PHPUnit 9+
parent::assertDirectoryDoesNotExist($directory, $message);
} else {
self::assertDirectoryNotExists($directory, $message);
}
}
}
2 changes: 1 addition & 1 deletion src/MountManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public function failing_a_one_param_method(string $method, FilesystemOperationFa
$this->mountManager->{$method}('first://location.txt');
}

public function dpMetadataRetrieverMethods(): iterable
public static function dpMetadataRetrieverMethods(): iterable
{
yield 'mimeType' => ['mimeType', UnableToRetrieveMetadata::mimeType('location.txt')];
yield 'fileSize' => ['fileSize', UnableToRetrieveMetadata::fileSize('location.txt')];
Expand Down
2 changes: 1 addition & 1 deletion src/PathPrefixerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function an_absolute_root_path_is_supported(string $rootPath, string $sep
$this->assertEquals($expectedPath, $prefixedPath);
}

public function dpRootPaths(): iterable
public static function dpRootPaths(): iterable
{
yield "unix-style root path" => ['/', '/', 'path.txt', '/path.txt'];
yield "windows-style root path" => ['\\', '\\', 'path.txt', '\\path.txt'];
Expand Down
2 changes: 1 addition & 1 deletion src/ReadOnly/ReadOnlyFilesystemAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function can_perform_read_operations(): void
$this->assertInstanceOf(FileAttributes::class, $adapter->mimeType('foo/bar.txt'));
$this->assertInstanceOf(FileAttributes::class, $adapter->lastModified('foo/bar.txt'));
$this->assertInstanceOf(FileAttributes::class, $adapter->fileSize('foo/bar.txt'));
$this->assertCount(1, $adapter->listContents('foo', true));
$this->assertCount(1, iterator_to_array($adapter->listContents('foo', true)));
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/WhitespacePathNormalizerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function path_normalizing(string $input, string $expected): void
/**
* @return array<array<string>>
*/
public function pathProvider(): array
public static function pathProvider(): array
{
return [
['.', ''],
Expand Down Expand Up @@ -78,15 +78,15 @@ public function rejecting_funky_whitespace(string $path): void
$this->normalizer->normalizePath($path);
}

public function dpFunkyWhitespacePaths(): iterable
public static function dpFunkyWhitespacePaths(): iterable
{
return [["some\0/path.txt"], ["s\x09i.php"]];
}

/**
* @return array<array<string>>
*/
public function invalidPathProvider(): array
public static function invalidPathProvider(): array
{
return [
['something/../../../hehe'],
Expand Down
2 changes: 1 addition & 1 deletion src/ZipArchive/NoRootPrefixZipArchiveAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
/**
* @group zip
*/
final class NoRootPrefixZipArchiveAdapterTest extends ZipArchiveAdapterTest
final class NoRootPrefixZipArchiveAdapterTest extends ZipArchiveAdapterTestCase
{
protected static function getRoot(): string
{
Expand Down
2 changes: 1 addition & 1 deletion src/ZipArchive/PrefixedRootZipArchiveAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
/**
* @group zip
*/
final class PrefixedRootZipArchiveAdapterTest extends ZipArchiveAdapterTest
final class PrefixedRootZipArchiveAdapterTest extends ZipArchiveAdapterTestCase
{
protected static function getRoot(): string
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
/**
* @group zip
*/
abstract class ZipArchiveAdapterTest extends FilesystemAdapterTestCase
abstract class ZipArchiveAdapterTestCase extends FilesystemAdapterTestCase
{
private const ARCHIVE = __DIR__ . '/test.zip';

Expand Down Expand Up @@ -97,7 +97,7 @@ public function scenarios_that_cause_writing_a_file_to_fail(callable $scenario):
});
}

public function scenariosThatCauseWritesToFail(): Generator
public static function scenariosThatCauseWritesToFail(): Generator
{
yield "writing a file fails when writing" => [function () {
static::$archiveProvider->stubbedZipArchive()->failNextWrite();
Expand Down Expand Up @@ -172,8 +172,8 @@ public function list_root_directory(): void
$this->givenWeHaveAnExistingFile('one/b.txt');
$this->givenWeHaveAnExistingFile('two/a.txt');

$this->assertCount(6, $this->adapter()->listContents('', true));
$this->assertCount(3, $this->adapter()->listContents('', false));
$this->assertCount(6, iterator_to_array($this->adapter()->listContents('', true)));
$this->assertCount(3, iterator_to_array($this->adapter()->listContents('', false)));
}

/**
Expand Down
Loading