diff --git a/rector.php b/rector.php index a095a00..d100097 100644 --- a/rector.php +++ b/rector.php @@ -5,10 +5,10 @@ use Rector\Config\RectorConfig; use Rector\Naming\Rector\Assign\RenameVariableToMatchMethodCallReturnTypeRector; use Rector\Naming\Rector\ClassMethod\RenameParamToMatchTypeRector; -use Rector\PHPUnit\Rector\Class_\AddSeeTestAnnotationRector; +use Rector\PHPUnit\CodeQuality\Rector\Class_\AddSeeTestAnnotationRector; +use Rector\PHPUnit\CodeQuality\Rector\ClassMethod\ReplaceTestAnnotationWithPrefixedFunctionRector; use Rector\PHPUnit\Set\PHPUnitSetList; use Rector\Privatization\Rector\Class_\FinalizeClassesWithoutChildrenRector; -use Rector\Privatization\Rector\Class_\RepeatedLiteralToClassConstantRector; use Rector\Privatization\Rector\MethodCall\PrivatizeLocalGetterToPropertyRector; use Rector\Set\ValueObject\LevelSetList; use Zing\CodingStandard\Set\RectorSetList; @@ -23,8 +23,8 @@ RenameParamToMatchTypeRector::class, AddSeeTestAnnotationRector::class, FinalizeClassesWithoutChildrenRector::class, - RepeatedLiteralToClassConstantRector::class, PrivatizeLocalGetterToPropertyRector::class, + ReplaceTestAnnotationWithPrefixedFunctionRector::class => [__DIR__ . '/tests/ObsAdapterTest.php'], ] ); $rectorConfig->paths([__DIR__ . '/src', __DIR__ . '/tests', __DIR__ . '/ecs.php', __DIR__ . '/rector.php']); diff --git a/tests/InvalidAdapterTest.php b/tests/InvalidAdapterTest.php index 497058e..9b6b4cd 100644 --- a/tests/InvalidAdapterTest.php +++ b/tests/InvalidAdapterTest.php @@ -119,7 +119,7 @@ public function testGetVisibility(): void public function testListContents(): void { $this->expectException(ObsException::class); - self::assertEmpty(iterator_to_array($this->obsAdapter->listContents('/', false))); + $this->assertEmpty(iterator_to_array($this->obsAdapter->listContents('/', false))); } public function testGetSize(): void @@ -145,7 +145,7 @@ public function testGetMimetype(): void public function testHas(): void { - self::assertFalse($this->obsAdapter->fileExists('file.txt')); + $this->assertFalse($this->obsAdapter->fileExists('file.txt')); } public function testBucket(): void @@ -153,7 +153,7 @@ public function testBucket(): void $obsAdapter = new ObsAdapter($this->obsClient, self::CONFIG['bucket'], '', null, null, [ 'endpoint' => 'http://obs.cdn.com', ]); - self::assertSame('test', $obsAdapter->getBucket()); + $this->assertSame('test', $obsAdapter->getBucket()); } public function testSetBucket(): void @@ -162,7 +162,7 @@ public function testSetBucket(): void 'endpoint' => 'http://obs.cdn.com', ]); $obsAdapter->setBucket('new-bucket'); - self::assertSame('new-bucket', $obsAdapter->getBucket()); + $this->assertSame('new-bucket', $obsAdapter->getBucket()); } public function testGetUrl(): void @@ -170,7 +170,7 @@ public function testGetUrl(): void $obsAdapter = new ObsAdapter($this->obsClient, self::CONFIG['bucket'], '', null, null, [ 'endpoint' => 'http://obs.cdn.com', ]); - self::assertSame('http://test.obs.cdn.com/test', $obsAdapter->getUrl('test')); + $this->assertSame('http://test.obs.cdn.com/test', $obsAdapter->getUrl('test')); } public function testGetClient(): void @@ -178,8 +178,8 @@ public function testGetClient(): void $obsAdapter = new ObsAdapter($this->obsClient, self::CONFIG['bucket'], '', null, null, [ 'endpoint' => 'http://obs.cdn.com', ]); - self::assertSame($this->obsClient, $obsAdapter->getClient()); - self::assertSame($this->obsClient, $obsAdapter->kernel()); + $this->assertSame($this->obsClient, $obsAdapter->getClient()); + $this->assertSame($this->obsClient, $obsAdapter->kernel()); } public function testGetUrlWithoutSchema(): void @@ -187,7 +187,7 @@ public function testGetUrlWithoutSchema(): void $obsAdapter = new ObsAdapter($this->obsClient, self::CONFIG['bucket'], '', null, null, [ 'endpoint' => 'obs.cdn.com', ]); - self::assertSame('https://test.obs.cdn.com/test', $obsAdapter->getUrl('test')); + $this->assertSame('https://test.obs.cdn.com/test', $obsAdapter->getUrl('test')); } public function testGetUrlWithoutEndpoint(): void @@ -204,7 +204,7 @@ public function testGetUrlWithUrl(): void 'endpoint' => 'https://obs.cdn.com', 'url' => 'https://obs.cdn.com', ]); - self::assertSame('https://obs.cdn.com/test', $obsAdapter->getUrl('test')); + $this->assertSame('https://obs.cdn.com/test', $obsAdapter->getUrl('test')); } public function testGetUrlWithBucketEndpoint(): void @@ -213,7 +213,7 @@ public function testGetUrlWithBucketEndpoint(): void 'endpoint' => 'https://obs.cdn.com', 'bucket_endpoint' => true, ]); - self::assertSame('https://obs.cdn.com/test', $obsAdapter->getUrl('test')); + $this->assertSame('https://obs.cdn.com/test', $obsAdapter->getUrl('test')); } public function testGetTemporaryUrlWithUrl(): void @@ -222,13 +222,13 @@ public function testGetTemporaryUrlWithUrl(): void 'endpoint' => 'https://obs.cdn.com', 'temporary_url' => 'https://obs.cdn.com', ]); - self::assertStringStartsWith('https://obs.cdn.com/test', $obsAdapter->getTemporaryUrl('test', 10)); + $this->assertStringStartsWith('https://obs.cdn.com/test', $obsAdapter->getTemporaryUrl('test', 10)); } public function testDirectoryExists(): void { if (! class_exists(UnableToCheckDirectoryExistence::class)) { - self::markTestSkipped('Require League Flysystem v3'); + $this->markTestSkipped('Require League Flysystem v3'); } $this->expectException(UnableToCheckDirectoryExistence::class); diff --git a/tests/MockAdapterTest.php b/tests/MockAdapterTest.php index 568908f..51c7b88 100644 --- a/tests/MockAdapterTest.php +++ b/tests/MockAdapterTest.php @@ -76,7 +76,7 @@ public function testCopy(): void $this->mockGetVisibility('file.txt', Visibility::PUBLIC); $this->obsAdapter->copy('file.txt', 'copy.txt', new Config()); $this->mockGetObject('copy.txt', 'write'); - self::assertSame('write', $this->obsAdapter->read('copy.txt')); + $this->assertSame('write', $this->obsAdapter->read('copy.txt')); } public function testCopyFailed(): void @@ -97,7 +97,7 @@ public function testCopyFailed(): void $this->expectException(UnableToCopyFile::class); $this->obsAdapter->copy('file.txt', 'copy.txt', new Config()); $this->mockGetObject('copy.txt', 'write'); - self::assertSame('write', $this->obsAdapter->read('copy.txt')); + $this->assertSame('write', $this->obsAdapter->read('copy.txt')); } private function mockGetObject(string $path, string $body): void @@ -250,10 +250,10 @@ public function testCreateDir(): void ], ]); $this->obsAdapter->createDirectory('path', new Config()); - self::assertTrue($this->obsAdapter->directoryExists('path')); - self::assertSame([], iterator_to_array($this->obsAdapter->listContents('path', false))); + $this->assertTrue($this->obsAdapter->directoryExists('path')); + $this->assertSame([], iterator_to_array($this->obsAdapter->listContents('path', false))); $this->obsAdapter->deleteDirectory('path'); - self::assertFalse($this->obsAdapter->directoryExists('path')); + $this->assertFalse($this->obsAdapter->directoryExists('path')); } public function testSetVisibility(): void @@ -322,7 +322,7 @@ public function testSetVisibility(): void 'HttpStatusCode' => 200, 'Reason' => 'OK', ])); - self::assertSame(Visibility::PRIVATE, $this->obsAdapter->visibility('file.txt')->visibility()); + $this->assertSame(Visibility::PRIVATE, $this->obsAdapter->visibility('file.txt')->visibility()); $this->legacyMock->shouldReceive('setObjectAcl') ->withArgs([ [ @@ -341,7 +341,7 @@ public function testSetVisibility(): void ])); $this->obsAdapter->setVisibility('file.txt', Visibility::PUBLIC); - self::assertSame(Visibility::PUBLIC, $this->obsAdapter->visibility('file.txt')['visibility']); + $this->assertSame(Visibility::PUBLIC, $this->obsAdapter->visibility('file.txt')['visibility']); } public function testRename(): void @@ -349,7 +349,7 @@ public function testRename(): void $this->mockPutObject('from.txt', 'write'); $this->obsAdapter->write('from.txt', 'write', new Config()); $this->mockGetMetadata('from.txt'); - self::assertTrue($this->obsAdapter->fileExists('from.txt')); + $this->assertTrue($this->obsAdapter->fileExists('from.txt')); $this->legacyMock->shouldReceive('getObjectMetadata') ->withArgs([ [ @@ -357,7 +357,7 @@ public function testRename(): void 'Key' => 'to.txt', ], ])->andThrow(new ObsException()); - self::assertFalse($this->obsAdapter->fileExists('to.txt')); + $this->assertFalse($this->obsAdapter->fileExists('to.txt')); $this->legacyMock->shouldReceive('copyObject') ->withArgs([ [ @@ -384,9 +384,9 @@ public function testRename(): void 'Key' => 'from.txt', ], ])->andThrow(new ObsException()); - self::assertFalse($this->obsAdapter->fileExists('from.txt')); + $this->assertFalse($this->obsAdapter->fileExists('from.txt')); $this->mockGetObject('to.txt', 'write'); - self::assertSame('write', $this->obsAdapter->read('to.txt')); + $this->assertSame('write', $this->obsAdapter->read('to.txt')); $this->legacyMock->shouldReceive('deleteObject') ->withArgs([ [ @@ -472,7 +472,7 @@ public function testDeleteDir(): void ], ])->andReturn(new Model()); $this->obsAdapter->deleteDirectory('path'); - self::assertTrue(true); + $this->assertTrue(true); } public function testWriteStream(): void @@ -481,7 +481,7 @@ public function testWriteStream(): void $this->mockPutObject('file.txt', $contents); $this->obsAdapter->writeStream('file.txt', $contents, new Config()); $this->mockGetObject('file.txt', 'write'); - self::assertSame('write', $this->obsAdapter->read('file.txt')); + $this->assertSame('write', $this->obsAdapter->read('file.txt')); } /** @@ -559,7 +559,7 @@ public function testWriteStreamWithVisibility(string $visibility): void 'visibility' => $visibility, ])); $this->mockGetVisibility('file.txt', $visibility); - self::assertSame($visibility, $this->obsAdapter->visibility('file.txt')['visibility']); + $this->assertSame($visibility, $this->obsAdapter->visibility('file.txt')['visibility']); } public function testWriteStreamWithExpires(): void @@ -579,7 +579,7 @@ public function testWriteStreamWithExpires(): void 'Expires' => 20, ])); $this->mockGetObject('file.txt', 'write'); - self::assertSame('write', $this->obsAdapter->read('file.txt')); + $this->assertSame('write', $this->obsAdapter->read('file.txt')); } public function testWriteStreamWithMimetype(): void @@ -631,7 +631,7 @@ public function testWriteStreamWithMimetype(): void 'HttpStatusCode' => 200, 'Reason' => 'OK', ])); - self::assertSame('image/png', $this->obsAdapter->mimeType('file.txt')['mime_type']); + $this->assertSame('image/png', $this->obsAdapter->mimeType('file.txt')['mime_type']); } public function testDelete(): void @@ -640,7 +640,7 @@ public function testDelete(): void $this->mockPutObject('file.txt', $contents); $this->obsAdapter->writeStream('file.txt', $contents, new Config()); $this->mockGetMetadata('file.txt'); - self::assertTrue($this->obsAdapter->fileExists('file.txt')); + $this->assertTrue($this->obsAdapter->fileExists('file.txt')); $this->legacyMock->shouldReceive('deleteObject') ->withArgs([ [ @@ -656,7 +656,7 @@ public function testDelete(): void 'Key' => 'file.txt', ], ])->andThrow(new ObsException()); - self::assertFalse($this->obsAdapter->fileExists('file.txt')); + $this->assertFalse($this->obsAdapter->fileExists('file.txt')); } public function testWrite(): void @@ -664,20 +664,20 @@ public function testWrite(): void $this->mockPutObject('file.txt', 'write'); $this->obsAdapter->write('file.txt', 'write', new Config()); $this->mockGetObject('file.txt', 'write'); - self::assertSame('write', $this->obsAdapter->read('file.txt')); + $this->assertSame('write', $this->obsAdapter->read('file.txt')); } public function testRead(): void { $this->mockGetObject('fixture/read.txt', 'read-test'); - self::assertSame('read-test', $this->obsAdapter->read('fixture/read.txt')); + $this->assertSame('read-test', $this->obsAdapter->read('fixture/read.txt')); } public function testReadStream(): void { $this->mockGetObject('fixture/read.txt', 'read-test'); - self::assertSame('read-test', stream_get_contents($this->obsAdapter->readStream('fixture/read.txt'))); + $this->assertSame('read-test', stream_get_contents($this->obsAdapter->readStream('fixture/read.txt'))); } public function testGetVisibility(): void @@ -713,7 +713,7 @@ public function testGetVisibility(): void ], ], ])); - self::assertSame(Visibility::PRIVATE, $this->obsAdapter->visibility('fixture/read.txt')['visibility']); + $this->assertSame(Visibility::PRIVATE, $this->obsAdapter->visibility('fixture/read.txt')['visibility']); } private function mockGetMetadata(string $path): void @@ -875,7 +875,7 @@ public function testListContents(): void 'Reason' => 'OK', ] )); - self::assertNotEmpty(iterator_to_array($this->obsAdapter->listContents('path', false))); + $this->assertNotEmpty(iterator_to_array($this->obsAdapter->listContents('path', false))); $this->legacyMock->shouldReceive('listObjects') ->withArgs([ [ @@ -889,7 +889,7 @@ public function testListContents(): void 'NextMarker' => '', 'Contents' => [], ])); - self::assertEmpty(iterator_to_array($this->obsAdapter->listContents('path1', false))); + $this->assertEmpty(iterator_to_array($this->obsAdapter->listContents('path1', false))); $this->mockPutObject('a/b/file.txt', 'test'); $this->obsAdapter->write('a/b/file.txt', 'test', new Config()); $this->legacyMock->shouldReceive('listObjects') @@ -976,79 +976,79 @@ public function testListContents(): void ])); $this->mockGetMetadata('a/b/file.txt'); $contents = iterator_to_array($this->obsAdapter->listContents('a', true)); - self::assertContainsOnlyInstancesOf(StorageAttributes::class, $contents); - self::assertCount(2, $contents); + $this->assertContainsOnlyInstancesOf(StorageAttributes::class, $contents); + $this->assertCount(2, $contents); /** @var \League\Flysystem\FileAttributes $file */ $file = $contents[0]; - self::assertInstanceOf(FileAttributes::class, $file); - self::assertSame('a/b/file.txt', $file->path()); - self::assertSame(9, $file->fileSize()); + $this->assertInstanceOf(FileAttributes::class, $file); + $this->assertSame('a/b/file.txt', $file->path()); + $this->assertSame(9, $file->fileSize()); - self::assertNull($file->mimeType()); - self::assertSame(1_622_474_604, $file->lastModified()); - self::assertNull($file->visibility()); - self::assertSame([ + $this->assertNull($file->mimeType()); + $this->assertSame(1_622_474_604, $file->lastModified()); + $this->assertNull($file->visibility()); + $this->assertSame([ 'StorageClass' => 'STANDARD_IA', 'ETag' => 'd41d8cd98f00b204e9800998ecf8427e', ], $file->extraMetadata()); /** @var \League\Flysystem\DirectoryAttributes $directory */ $directory = $contents[1]; - self::assertInstanceOf(DirectoryAttributes::class, $directory); - self::assertSame('a/b', $directory->path()); + $this->assertInstanceOf(DirectoryAttributes::class, $directory); + $this->assertSame('a/b', $directory->path()); } public function testGetSize(): void { $this->mockGetMetadata('fixture/read.txt'); - self::assertSame(9, $this->obsAdapter->fileSize('fixture/read.txt')->fileSize()); + $this->assertSame(9, $this->obsAdapter->fileSize('fixture/read.txt')->fileSize()); } public function testGetSizeError(): void { $this->mockGetEmptyMetadata('fixture/read.txt'); $this->expectException(UnableToRetrieveMetadata::class); - self::assertSame(9, $this->obsAdapter->fileSize('fixture/read.txt')->fileSize()); + $this->assertSame(9, $this->obsAdapter->fileSize('fixture/read.txt')->fileSize()); } public function testGetTimestamp(): void { $this->mockGetMetadata('fixture/read.txt'); - self::assertSame(1_622_443_952, $this->obsAdapter->lastModified('fixture/read.txt')->lastModified()); + $this->assertSame(1_622_443_952, $this->obsAdapter->lastModified('fixture/read.txt')->lastModified()); } public function testGetTimestampError(): void { $this->mockGetEmptyMetadata('fixture/read.txt'); $this->expectException(UnableToRetrieveMetadata::class); - self::assertSame(1_622_443_952, $this->obsAdapter->lastModified('fixture/read.txt')->lastModified()); + $this->assertSame(1_622_443_952, $this->obsAdapter->lastModified('fixture/read.txt')->lastModified()); } public function testGetMimetype(): void { $this->mockGetMetadata('fixture/read.txt'); - self::assertSame('text/plain', $this->obsAdapter->mimeType('fixture/read.txt')->mimeType()); + $this->assertSame('text/plain', $this->obsAdapter->mimeType('fixture/read.txt')->mimeType()); } public function testGetMimetypeError(): void { $this->mockGetEmptyMetadata('fixture/read.txt'); $this->expectException(UnableToRetrieveMetadata::class); - self::assertSame('text/plain', $this->obsAdapter->mimeType('fixture/read.txt')->mimeType()); + $this->assertSame('text/plain', $this->obsAdapter->mimeType('fixture/read.txt')->mimeType()); } public function testGetMetadataError(): void { $this->mockGetEmptyMetadata('fixture/'); $this->expectException(UnableToRetrieveMetadata::class); - self::assertSame('text/plain', $this->obsAdapter->mimeType('fixture/')->mimeType()); + $this->assertSame('text/plain', $this->obsAdapter->mimeType('fixture/')->mimeType()); } public function testHas(): void { $this->mockGetMetadata('fixture/read.txt'); - self::assertTrue($this->obsAdapter->fileExists('fixture/read.txt')); + $this->assertTrue($this->obsAdapter->fileExists('fixture/read.txt')); } public function testGetTemporaryUrl(): void @@ -1065,7 +1065,7 @@ public function testGetTemporaryUrl(): void ])->andReturn(new Model([ 'SignedUrl' => 'signed-url', ])); - self::assertSame('signed-url', $this->obsAdapter->getTemporaryUrl('fixture/read.txt', 10, [])); + $this->assertSame('signed-url', $this->obsAdapter->getTemporaryUrl('fixture/read.txt', 10, [])); } public function testDirectoryExists(): void @@ -1138,9 +1138,9 @@ public function testDirectoryExists(): void 'Body' => null, ], ])->andReturn(new Model()); - self::assertFalse($this->obsAdapter->directoryExists('fixture/exists-directory')); + $this->assertFalse($this->obsAdapter->directoryExists('fixture/exists-directory')); $this->obsAdapter->createDirectory('fixture/exists-directory', new Config()); - self::assertTrue($this->obsAdapter->directoryExists('fixture/exists-directory')); + $this->assertTrue($this->obsAdapter->directoryExists('fixture/exists-directory')); } public function testMovingAFileWithVisibility(): void @@ -1184,16 +1184,16 @@ public function testMovingAFileWithVisibility(): void $adapter->move('source.txt', 'destination.txt', new Config([ Config::OPTION_VISIBILITY => Visibility::PRIVATE, ])); - self::assertFalse( + $this->assertFalse( $adapter->fileExists('source.txt'), 'After moving a file should no longer exist in the original location.' ); - self::assertTrue( + $this->assertTrue( $adapter->fileExists('destination.txt'), 'After moving, a file should be present at the new location.' ); - self::assertSame(Visibility::PRIVATE, $adapter->visibility('destination.txt')->visibility()); - self::assertSame('contents to be copied', $adapter->read('destination.txt')); + $this->assertSame(Visibility::PRIVATE, $adapter->visibility('destination.txt')->visibility()); + $this->assertSame('contents to be copied', $adapter->read('destination.txt')); } public function testCopyingAFileWithVisibility(): void @@ -1233,9 +1233,9 @@ public function testCopyingAFileWithVisibility(): void Config::OPTION_VISIBILITY => Visibility::PRIVATE, ])); - self::assertTrue($adapter->fileExists('source.txt')); - self::assertTrue($adapter->fileExists('destination.txt')); - self::assertSame(Visibility::PRIVATE, $adapter->visibility('destination.txt')->visibility()); - self::assertSame('contents to be copied', $adapter->read('destination.txt')); + $this->assertTrue($adapter->fileExists('source.txt')); + $this->assertTrue($adapter->fileExists('destination.txt')); + $this->assertSame(Visibility::PRIVATE, $adapter->visibility('destination.txt')->visibility()); + $this->assertSame('contents to be copied', $adapter->read('destination.txt')); } } diff --git a/tests/ObsAdapterTest.php b/tests/ObsAdapterTest.php index b839fe1..1ff5a40 100644 --- a/tests/ObsAdapterTest.php +++ b/tests/ObsAdapterTest.php @@ -38,7 +38,7 @@ protected static function createFilesystemAdapter(): FilesystemAdapter protected function setUp(): void { if ((string) getenv('MOCK') !== 'false') { - self::markTestSkipped('Mock tests enabled'); + $this->markTestSkipped('Mock tests enabled'); } $this->filesystemAdapter = self::createFilesystemAdapter(); @@ -68,7 +68,7 @@ public function fetching_unknown_mime_type_of_a_file(): void ->write('unknown-mime-type.md5', '', new Config()); $this->runScenario(function (): void { - self::assertSame('binary/octet-stream', $this->adapter()->mimeType('unknown-mime-type.md5')->mimeType()); + $this->assertSame('binary/octet-stream', $this->adapter()->mimeType('unknown-mime-type.md5')->mimeType()); }); } } diff --git a/tests/ValidAdapterTest.php b/tests/ValidAdapterTest.php index ac08e89..9dc27e8 100644 --- a/tests/ValidAdapterTest.php +++ b/tests/ValidAdapterTest.php @@ -42,7 +42,7 @@ private function getEndpoint(): string protected function setUp(): void { if ((string) getenv('MOCK') !== 'false') { - self::markTestSkipped('Mock tests enabled'); + $this->markTestSkipped('Mock tests enabled'); } parent::setUp(); @@ -71,62 +71,62 @@ public function testCopy(): void { $this->obsAdapter->write('fixture/file.txt', 'write', new Config()); $this->obsAdapter->copy('fixture/file.txt', 'fixture/copy.txt', new Config()); - self::assertSame('write', $this->obsAdapter->read('fixture/copy.txt')); + $this->assertSame('write', $this->obsAdapter->read('fixture/copy.txt')); } public function testCreateDir(): void { $this->obsAdapter->createDirectory('fixture/path', new Config()); - self::assertTrue($this->obsAdapter->directoryExists('fixture/path')); - self::assertSame([], iterator_to_array($this->obsAdapter->listContents('fixture/path', false))); - self::assertSame([], iterator_to_array($this->obsAdapter->listContents('fixture/path/', false))); + $this->assertTrue($this->obsAdapter->directoryExists('fixture/path')); + $this->assertSame([], iterator_to_array($this->obsAdapter->listContents('fixture/path', false))); + $this->assertSame([], iterator_to_array($this->obsAdapter->listContents('fixture/path/', false))); $this->obsAdapter->write('fixture/path1/file.txt', 'test', new Config()); $contents = iterator_to_array($this->obsAdapter->listContents('fixture/path1', false)); - self::assertCount(1, $contents); + $this->assertCount(1, $contents); $file = $contents[0]; - self::assertSame('fixture/path1/file.txt', $file['path']); + $this->assertSame('fixture/path1/file.txt', $file['path']); $this->obsAdapter->deleteDirectory('fixture/path'); - self::assertFalse($this->obsAdapter->directoryExists('fixture/path')); + $this->assertFalse($this->obsAdapter->directoryExists('fixture/path')); $this->obsAdapter->deleteDirectory('fixture/path1'); - self::assertFalse($this->obsAdapter->directoryExists('fixture/path1')); + $this->assertFalse($this->obsAdapter->directoryExists('fixture/path1')); } public function testDirectoryExists(): void { - self::assertFalse($this->obsAdapter->directoryExists('fixture/exists-directory')); + $this->assertFalse($this->obsAdapter->directoryExists('fixture/exists-directory')); $this->obsAdapter->createDirectory('fixture/exists-directory', new Config()); - self::assertTrue($this->obsAdapter->directoryExists('fixture/exists-directory')); + $this->assertTrue($this->obsAdapter->directoryExists('fixture/exists-directory')); } public function testSetVisibility(): void { $this->obsAdapter->write('fixture/file.txt', 'write', new Config()); - self::assertSame(Visibility::PRIVATE, $this->obsAdapter->visibility('fixture/file.txt')['visibility']); + $this->assertSame(Visibility::PRIVATE, $this->obsAdapter->visibility('fixture/file.txt')['visibility']); $this->obsAdapter->setVisibility('fixture/file.txt', Visibility::PUBLIC); - self::assertSame(Visibility::PUBLIC, $this->obsAdapter->visibility('fixture/file.txt')['visibility']); + $this->assertSame(Visibility::PUBLIC, $this->obsAdapter->visibility('fixture/file.txt')['visibility']); } public function testRename(): void { $this->obsAdapter->write('fixture/from.txt', 'write', new Config()); - self::assertTrue($this->obsAdapter->fileExists('fixture/from.txt')); - self::assertFalse($this->obsAdapter->fileExists('fixture/to.txt')); + $this->assertTrue($this->obsAdapter->fileExists('fixture/from.txt')); + $this->assertFalse($this->obsAdapter->fileExists('fixture/to.txt')); $this->obsAdapter->move('fixture/from.txt', 'fixture/to.txt', new Config()); - self::assertFalse($this->obsAdapter->fileExists('fixture/from.txt')); - self::assertSame('write', $this->obsAdapter->read('fixture/to.txt')); + $this->assertFalse($this->obsAdapter->fileExists('fixture/from.txt')); + $this->assertSame('write', $this->obsAdapter->read('fixture/to.txt')); $this->obsAdapter->delete('fixture/to.txt'); } public function testDeleteDir(): void { $this->obsAdapter->deleteDirectory('fixture'); - self::assertFalse($this->obsAdapter->directoryExists('fixture')); + $this->assertFalse($this->obsAdapter->directoryExists('fixture')); } public function testWriteStream(): void { $this->obsAdapter->writeStream('fixture/file.txt', $this->streamForResource('write'), new Config()); - self::assertSame('write', $this->obsAdapter->read('fixture/file.txt')); + $this->assertSame('write', $this->obsAdapter->read('fixture/file.txt')); } /** @@ -147,7 +147,7 @@ public function testWriteStreamWithVisibility(string $visibility): void $this->obsAdapter->writeStream('fixture/file.txt', $this->streamForResource('write'), new Config([ 'visibility' => $visibility, ])); - self::assertSame($visibility, $this->obsAdapter->visibility('fixture/file.txt')['visibility']); + $this->assertSame($visibility, $this->obsAdapter->visibility('fixture/file.txt')['visibility']); } public function testWriteStreamWithExpires(): void @@ -155,7 +155,7 @@ public function testWriteStreamWithExpires(): void $this->obsAdapter->writeStream('fixture/file.txt', $this->streamForResource('write'), new Config([ 'Expires' => 20, ])); - self::assertSame('write', $this->obsAdapter->read('fixture/file.txt')); + $this->assertSame('write', $this->obsAdapter->read('fixture/file.txt')); } public function testWriteStreamWithMimetype(): void @@ -163,87 +163,87 @@ public function testWriteStreamWithMimetype(): void $this->obsAdapter->writeStream('fixture/file.txt', $this->streamForResource('write'), new Config([ 'ContentType' => 'image/png', ])); - self::assertSame('image/png', $this->obsAdapter->mimeType('fixture/file.txt')['mime_type']); + $this->assertSame('image/png', $this->obsAdapter->mimeType('fixture/file.txt')['mime_type']); } public function testDelete(): void { $this->obsAdapter->writeStream('fixture/file.txt', $this->streamForResource('test'), new Config()); - self::assertTrue($this->obsAdapter->fileExists('fixture/file.txt')); + $this->assertTrue($this->obsAdapter->fileExists('fixture/file.txt')); $this->obsAdapter->delete('fixture/file.txt'); - self::assertFalse($this->obsAdapter->fileExists('fixture/file.txt')); + $this->assertFalse($this->obsAdapter->fileExists('fixture/file.txt')); } public function testWrite(): void { $this->obsAdapter->write('fixture/file.txt', 'write', new Config()); - self::assertSame('write', $this->obsAdapter->read('fixture/file.txt')); + $this->assertSame('write', $this->obsAdapter->read('fixture/file.txt')); } public function testRead(): void { - self::assertSame('read-test', $this->obsAdapter->read('fixture/read.txt')); + $this->assertSame('read-test', $this->obsAdapter->read('fixture/read.txt')); } public function testReadStream(): void { - self::assertSame('read-test', stream_get_contents($this->obsAdapter->readStream('fixture/read.txt'))); + $this->assertSame('read-test', stream_get_contents($this->obsAdapter->readStream('fixture/read.txt'))); } public function testGetVisibility(): void { - self::assertSame(Visibility::PRIVATE, $this->obsAdapter->visibility('fixture/read.txt')->visibility()); + $this->assertSame(Visibility::PRIVATE, $this->obsAdapter->visibility('fixture/read.txt')->visibility()); } public function testListContents(): void { - self::assertNotEmpty(iterator_to_array($this->obsAdapter->listContents('fixture', false))); - self::assertEmpty(iterator_to_array($this->obsAdapter->listContents('path1', false))); + $this->assertNotEmpty(iterator_to_array($this->obsAdapter->listContents('fixture', false))); + $this->assertEmpty(iterator_to_array($this->obsAdapter->listContents('path1', false))); $this->obsAdapter->createDirectory('fixture/path/dir', new Config()); $this->obsAdapter->write('fixture/path/dir/file.txt', 'test', new Config()); /** @var \League\Flysystem\StorageAttributes[] $contents */ $contents = iterator_to_array($this->obsAdapter->listContents('fixture/path', true)); - self::assertContainsOnlyInstancesOf(StorageAttributes::class, $contents); - self::assertCount(2, $contents); + $this->assertContainsOnlyInstancesOf(StorageAttributes::class, $contents); + $this->assertCount(2, $contents); /** @var \League\Flysystem\FileAttributes $file */ /** @var \League\Flysystem\DirectoryAttributes $directory */ [$file,$directory] = $contents[0]->isFile() ? [$contents[0], $contents[1]] : [$contents[1], $contents[0]]; - self::assertInstanceOf(FileAttributes::class, $file); - self::assertSame('fixture/path/dir/file.txt', $file->path()); - self::assertSame(4, $file->fileSize()); + $this->assertInstanceOf(FileAttributes::class, $file); + $this->assertSame('fixture/path/dir/file.txt', $file->path()); + $this->assertSame(4, $file->fileSize()); - self::assertNull($file->mimeType()); - self::assertNotNull($file->lastModified()); - self::assertNull($file->visibility()); - self::assertIsArray($file->extraMetadata()); - self::assertInstanceOf(DirectoryAttributes::class, $directory); - self::assertSame('fixture/path/dir', $directory->path()); + $this->assertNull($file->mimeType()); + $this->assertNotNull($file->lastModified()); + $this->assertNull($file->visibility()); + $this->assertIsArray($file->extraMetadata()); + $this->assertInstanceOf(DirectoryAttributes::class, $directory); + $this->assertSame('fixture/path/dir', $directory->path()); } public function testGetSize(): void { - self::assertSame(9, $this->obsAdapter->fileSize('fixture/read.txt')->fileSize()); + $this->assertSame(9, $this->obsAdapter->fileSize('fixture/read.txt')->fileSize()); } public function testGetTimestamp(): void { - self::assertGreaterThan(time() - 10, $this->obsAdapter->lastModified('fixture/read.txt')->lastModified()); + $this->assertGreaterThan(time() - 10, $this->obsAdapter->lastModified('fixture/read.txt')->lastModified()); } public function testGetMimetype(): void { - self::assertSame('text/plain', $this->obsAdapter->mimeType('fixture/read.txt')->mimeType()); + $this->assertSame('text/plain', $this->obsAdapter->mimeType('fixture/read.txt')->mimeType()); } public function testHas(): void { - self::assertTrue($this->obsAdapter->fileExists('fixture/read.txt')); + $this->assertTrue($this->obsAdapter->fileExists('fixture/read.txt')); } public function testGetTemporaryUrl(): void { - self::assertSame( + $this->assertSame( 'read-test', file_get_contents($this->obsAdapter->getTemporaryUrl('fixture/read.txt', 10, [])) ); @@ -253,7 +253,7 @@ public function testImage(): void { $contents = file_get_contents('https://avatars.githubusercontent.com/u/26657141'); if ($contents === false) { - self::markTestSkipped('Require image contents'); + $this->markTestSkipped('Require image contents'); } $this->obsAdapter->write('fixture/image.png', $contents, new Config()); @@ -263,8 +263,8 @@ public function testImage(): void 'x-image-process' => 'image/crop,w_200,h_100', ])); - self::assertSame(200, $info[0]); - self::assertSame(100, $info[1]); + $this->assertSame(200, $info[0]); + $this->assertSame(100, $info[1]); } public function testForceMimetype(): void @@ -272,11 +272,11 @@ public function testForceMimetype(): void $this->obsAdapter->write('fixture/file.txt', 'test', new Config([ 'mimetype' => 'image/png', ])); - self::assertSame('image/png', $this->obsAdapter->mimeType('fixture/file.txt')->mimeType()); + $this->assertSame('image/png', $this->obsAdapter->mimeType('fixture/file.txt')->mimeType()); $this->obsAdapter->write('fixture/file2.txt', 'test', new Config([ 'ContentType' => 'image/png', ])); - self::assertSame('image/png', $this->obsAdapter->mimeType('fixture/file2.txt')->mimeType()); + $this->assertSame('image/png', $this->obsAdapter->mimeType('fixture/file2.txt')->mimeType()); } public function testMovingAFileWithVisibility(): void @@ -292,16 +292,16 @@ public function testMovingAFileWithVisibility(): void $adapter->move('source.txt', 'destination.txt', new Config([ Config::OPTION_VISIBILITY => Visibility::PRIVATE, ])); - self::assertFalse( + $this->assertFalse( $adapter->fileExists('source.txt'), 'After moving a file should no longer exist in the original location.' ); - self::assertTrue( + $this->assertTrue( $adapter->fileExists('destination.txt'), 'After moving, a file should be present at the new location.' ); - self::assertSame(Visibility::PRIVATE, $adapter->visibility('destination.txt')->visibility()); - self::assertSame('contents to be copied', $adapter->read('destination.txt')); + $this->assertSame(Visibility::PRIVATE, $adapter->visibility('destination.txt')->visibility()); + $this->assertSame('contents to be copied', $adapter->read('destination.txt')); } public function testCopyingAFileWithVisibility(): void @@ -319,9 +319,9 @@ public function testCopyingAFileWithVisibility(): void Config::OPTION_VISIBILITY => Visibility::PRIVATE, ])); - self::assertTrue($adapter->fileExists('source.txt')); - self::assertTrue($adapter->fileExists('destination.txt')); - self::assertSame(Visibility::PRIVATE, $adapter->visibility('destination.txt')->visibility()); - self::assertSame('contents to be copied', $adapter->read('destination.txt')); + $this->assertTrue($adapter->fileExists('source.txt')); + $this->assertTrue($adapter->fileExists('destination.txt')); + $this->assertSame(Visibility::PRIVATE, $adapter->visibility('destination.txt')->visibility()); + $this->assertSame('contents to be copied', $adapter->read('destination.txt')); } }