From 10b9d4de4c80010b4f8e66bcb1c48c640d9ba0f1 Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Mon, 26 Feb 2024 15:10:40 +0545 Subject: [PATCH] test: adjust integration tests --- .../Owncloud/OcisPhpSdk/DriveTest.php | 6 +- .../Owncloud/OcisPhpSdk/GroupsTest.php | 34 +++---- .../Owncloud/OcisPhpSdk/NotificationTest.php | 9 +- .../OcisPhpSdk/OcisPhpSdkTestCase.php | 18 ++-- .../Owncloud/OcisPhpSdk/OcisResourceTest.php | 96 +++++++++---------- .../Owncloud/OcisPhpSdk/OcisTest.php | 66 ++++++------- .../OcisPhpSdk/ResourceInviteTest.php | 12 --- .../OcisPhpSdk/ResourceShareLinkTest.php | 7 +- .../OcisPhpSdk/ShareCreatedModifyTest.php | 3 - .../OcisPhpSdk/ShareGetShareByMeTest.php | 10 +- .../OcisPhpSdk/ShareGetSharedWithMeTest.php | 30 ++---- ...TestGetSharedWithMeNotSyncedSharesTest.php | 10 +- .../Owncloud/OcisPhpSdk/UsersTest.php | 4 +- 13 files changed, 131 insertions(+), 174 deletions(-) diff --git a/tests/integration/Owncloud/OcisPhpSdk/DriveTest.php b/tests/integration/Owncloud/OcisPhpSdk/DriveTest.php index e2450cdc..83d022fb 100644 --- a/tests/integration/Owncloud/OcisPhpSdk/DriveTest.php +++ b/tests/integration/Owncloud/OcisPhpSdk/DriveTest.php @@ -23,16 +23,16 @@ public function setUp(): void public function testDisableDrive(): void { - $this->assertFalse($this->drive->isDisabled(), $this->drive->getName(). " drive is expected to be enabled initially"); + $this->assertFalse($this->drive->isDisabled(), $this->drive->getName() . " drive is expected to be enabled initially"); $this->drive->disable(); - $this->assertTrue($this->drive->isDisabled(), "Failed to disable the drive ".$this->drive->getName()); + $this->assertTrue($this->drive->isDisabled(), "Failed to disable the drive " . $this->drive->getName()); } public function testEnableDrive(): void { $this->drive->disable(); $this->drive->enable(); - $this->assertFalse($this->drive->isDisabled(), "Failed to enable the drive ".$this->drive->getName()); + $this->assertFalse($this->drive->isDisabled(), "Failed to enable the drive " . $this->drive->getName()); } public function testEnableNotExistingDrive(): void diff --git a/tests/integration/Owncloud/OcisPhpSdk/GroupsTest.php b/tests/integration/Owncloud/OcisPhpSdk/GroupsTest.php index 1e1e1226..299dd73d 100644 --- a/tests/integration/Owncloud/OcisPhpSdk/GroupsTest.php +++ b/tests/integration/Owncloud/OcisPhpSdk/GroupsTest.php @@ -29,14 +29,14 @@ public function testAddUserToGroup(): void $this->assertCount( 1, $group->getMembers(), - "The group ".$group->getDisplayName() + "The group " . $group->getDisplayName() . " should have 1 member but found " - .count($group->getMembers())." members" + . count($group->getMembers()) . " members" ); - $this->assertEquals( + $this->assertSame( $userName, $group->getMembers()[0]->getDisplayName(), - $userName . " user be the first member". $group->getDisplayName() . " group but found " + $userName . " user be the first member" . $group->getDisplayName() . " group but found " . $group->getMembers()[0]->getDisplayName() ); } @@ -55,29 +55,29 @@ public function testRemoveExistingUserFromGroup(): void "philosophy haters group" ); $this->createdGroups = [$philosophyHatersGroup]; - foreach($users as $user) { + foreach ($users as $user) { $philosophyHatersGroup->addUser($user); } $initialMemberCount = count($philosophyHatersGroup->getMembers()); foreach ($users as $user) { - if($user->getDisplayName() === "Albert Einstein") { + if ($user->getDisplayName() === "Albert Einstein") { $philosophyHatersGroup->removeUser($user); } } $adminUserName = $users[0]->getDisplayName(); $createdGroup = $ocis->getGroups(expandMembers: true); - $this->assertEquals( + $this->assertSame( $initialMemberCount - 1, count($createdGroup[0]->getMembers()), - "Expected " .($initialMemberCount - 1) + "Expected " . ($initialMemberCount - 1) . " group member(s) but got " . count($createdGroup[0]->getMembers()) ); - $this->assertEquals( + $this->assertSame( $adminUserName, $createdGroup[0]->getMembers()[0]->getDisplayName(), "Username of group member should be " - . $adminUserName . " but found ".$createdGroup[0]->getMembers()[0]->getDisplayName() + . $adminUserName . " but found " . $createdGroup[0]->getMembers()[0]->getDisplayName() ); } @@ -94,13 +94,13 @@ public function testNormalUserRemoveExistingUserFromGroup(): void "philosophy haters group" ); $this->createdGroups = [$philosophyHatersGroup]; - foreach($users as $user) { + foreach ($users as $user) { $philosophyHatersGroup->addUser($user); } $einsteinPhilosophyHatersGroup = $einsteinUserOcis->getGroups("philosophyhaters")[0]; $this->expectException(UnauthorizedException::class); foreach ($users as $user) { - if($user->getDisplayName() === "Admin") { + if ($user->getDisplayName() === "Admin") { $einsteinPhilosophyHatersGroup->removeUser($user); } } @@ -184,13 +184,13 @@ public function testDeleteGroup(): void $this->assertCount( 1, $ocis->getGroups(), - "Expected one group but found ". count($ocis->getGroups()) + "Expected one group but found " . count($ocis->getGroups()) ); - $this->assertEquals( + $this->assertSame( "physicslovers", $ocis->getGroups()[0]->getDisplayName(), "Group should be deleted but exists " - .$ocis->getGroups()[0]->getDisplayName() + . $ocis->getGroups()[0]->getDisplayName() ); } @@ -208,13 +208,13 @@ public function testGetGroupsByNormalUser(): void $this->assertCount( 1, $groups, - "Expected one group but found ". count($groups) + "Expected one group but found " . count($groups) ); foreach ($groups as $group) { $this->assertInstanceOf( Group::class, $group, - "Expected class ".Group::class + "Expected class " . Group::class . " but got " . get_class($group) ); $this->assertIsString($group->getId()); diff --git a/tests/integration/Owncloud/OcisPhpSdk/NotificationTest.php b/tests/integration/Owncloud/OcisPhpSdk/NotificationTest.php index 67c4f92a..af9377c4 100644 --- a/tests/integration/Owncloud/OcisPhpSdk/NotificationTest.php +++ b/tests/integration/Owncloud/OcisPhpSdk/NotificationTest.php @@ -32,9 +32,6 @@ public function setUp(): void $this->einstein = $this->ocis->getUsers('einstein')[0]; - /** - * @var SharingRole $role - */ foreach ($this->fileToShare->getRoles() as $role) { if ($role->getDisplayName() === 'Viewer') { $this->viewerRole = $role; @@ -53,15 +50,15 @@ public function testGetNotifications(): void $this->assertContainsOnlyInstancesOf( Notification::class, $notifications, - "Array is not instance of ".Notification::class + "Array is not instance of " . Notification::class ); $this->assertCount( 1, $notifications, - "Expected one notification but received ". count($notifications) + "Expected one notification but received " . count($notifications) ); $this->assertSame( - $sharerUser[0]->getDisplayName(). + $sharerUser[0]->getDisplayName() . " shared to-share-test.txt with you", $notifications[0]->getMessage(), "Wrong Notification received" diff --git a/tests/integration/Owncloud/OcisPhpSdk/OcisPhpSdkTestCase.php b/tests/integration/Owncloud/OcisPhpSdk/OcisPhpSdkTestCase.php index 5c36e081..74cd9c09 100644 --- a/tests/integration/Owncloud/OcisPhpSdk/OcisPhpSdkTestCase.php +++ b/tests/integration/Owncloud/OcisPhpSdk/OcisPhpSdkTestCase.php @@ -24,20 +24,20 @@ class OcisPhpSdkTestCase extends TestCase private ?string $tokenUrl = null; private ?Client $guzzleClient = null; /** - * @var array + * @var array */ - protected $createdDrives = []; + protected array $createdDrives = []; /** * list of files and folders that were created during the tests * currently only for the personal drive - * @var array > driveId[] => resourcePath + * @var array> driveId[] => resourcePath */ - protected $createdResources = []; + protected array $createdResources = []; /** - * @var array <\Owncloud\OcisPhpSdk\Group> + * @var array<\Owncloud\OcisPhpSdk\Group> */ - protected $createdGroups = []; + protected array $createdGroups = []; public function setUp(): void { @@ -61,7 +61,7 @@ public function tearDown(): void $drive = $ocis->getDriveById($driveId); $drive->disable(); $drive->delete(); - } catch (NotFoundException $e) { + } catch (NotFoundException) { // ignore, we don't care if the drive was already deleted } @@ -76,7 +76,7 @@ public function tearDown(): void foreach ($resources as $resource) { try { $drive->deleteResource($resource); - } catch (NotFoundException $e) { + } catch (NotFoundException) { // ignore, we don't care if the resource was already deleted } } @@ -224,7 +224,7 @@ protected static function setOcisSetting(string $key, string $value): void $response = self::getWrapperGuzzleClient()->request( 'PUT', '/config', - ['body' => '{"'. $key . '": "' . $value . '"}'] + ['body' => '{"' . $key . '": "' . $value . '"}'] ); if ($response->getStatusCode() !== 200) { throw new \Exception('Failed to set OCIS setting'); diff --git a/tests/integration/Owncloud/OcisPhpSdk/OcisResourceTest.php b/tests/integration/Owncloud/OcisPhpSdk/OcisResourceTest.php index 31105c83..ea4b54cc 100644 --- a/tests/integration/Owncloud/OcisPhpSdk/OcisResourceTest.php +++ b/tests/integration/Owncloud/OcisPhpSdk/OcisResourceTest.php @@ -79,12 +79,9 @@ public function testGetResources(): void $this->assertCount( 4, $resources, - "Expected 4 resources but found ". count($resources) + "Expected 4 resources but found " . count($resources) ); - /** - * @var OcisResource $resource - */ foreach ($resources as $resource) { $this->assertMatchesRegularExpression( "/^" . $this->getFileIdRegex() . "$/i", @@ -92,12 +89,12 @@ public function testGetResources(): void "ResourceId doesn't match the expected format" ); $this->assertMatchesRegularExpression( - "/^\"[a-f0-9:\.]{1,32}\"$/", + "/^\"[a-f0-9:.]{1,32}\"$/", $resource->getEtag(), "Resource Etag doesn't match the expected format" ); $this->assertMatchesRegularExpression( - "?^" . $this->ocisUrl . '/f/'. $this->getFileIdRegex() . "$?i", + "?^" . $this->ocisUrl . '/f/' . $this->getFileIdRegex() . "$?i", $resource->getPrivatelink(), "Private Link of resource doesn't match the expected format" ); @@ -107,7 +104,7 @@ public function testGetResources(): void $this->equalTo("file"), $this->equalTo("folder") ), - "Expected resource type be either file or folder but found ".$resource->getType() + "Expected resource type be either file or folder but found " . $resource->getType() ); $this->assertMatchesRegularExpression( @@ -136,32 +133,31 @@ public function testGetResources(): void "Resources wasn't modified within 60 seconds" ); if ($resource->getType() === 'folder') { - $this->assertEquals( + $this->assertSame( '', $resource->getContentType(), - "Expected content type be empty but found ".$resource->getContentType() + "Expected content type be empty but found " . $resource->getContentType() ); } else { - $this->assertEquals( + $this->assertSame( 'text/plain', $resource->getContentType(), - "Expected content type be text/plain but found ".$resource->getContentType() + "Expected content type be text/plain but found " . $resource->getContentType() ); } - $this->assertEquals( - false, + $this->assertFalse( $resource->isFavorited(), "Resource is not expected to be favorited" ); - $this->assertEquals( + $this->assertSame( [], $resource->getTags(), - "Expected resource tag be empty array but found ". count($resource->getTags())." elements" + "Expected resource tag be empty array but found " . count($resource->getTags()) . " elements" ); $this->assertIsInt( $resource->getSize(), - "Expected resource size be of type integer but found ".getType($resource->getSize()) + "Expected resource size be of type integer but found " . getType($resource->getSize()) ); if ($resource->getType() === 'folder') { $this->assertThat( @@ -170,7 +166,7 @@ public function testGetResources(): void $this->equalTo("subfolder"), $this->equalTo("secondfolder") ), - "Expected resource name be subfolder or secondfolder but found ".$resource->getName() + "Expected resource name be subfolder or secondfolder but found " . $resource->getName() ); } else { $this->assertStringContainsString('file.txt', $resource->getName()); @@ -189,24 +185,24 @@ public function testGetResourceContent(): void $content = $this->getContentOfResource425Save($resource); switch ($resource->getName()) { case 'somefile.txt': - $this->assertEquals( + $this->assertSame( 'some content', $content, "File content doesn't match" ); break; case 'secondfile.txt': - $this->assertEquals( + $this->assertSame( 'some other content', $content, "File content doesn't match" ); break; case 'subfolder': - $this->assertEquals( + $this->assertSame( '', $content, - "Expected folder be empty but found ".$content + "Expected folder be empty but found " . $content ); break; } @@ -240,24 +236,24 @@ public function testGetResourceContentStream(): void $content = fread($stream, 1024); switch ($resource->getName()) { case 'somefile.txt': - $this->assertEquals( + $this->assertSame( 'some content', $content, "File content doesn't match" ); break; case 'secondfile.txt': - $this->assertEquals( + $this->assertSame( 'some other content', $content, "File content doesn't match" ); break; case 'subfolder': - $this->assertEquals( + $this->assertSame( '', $content, - "Expected folder be empty but found ".$content + "Expected folder be empty but found " . $content ); break; } @@ -271,15 +267,15 @@ public function testUploadFile(): void $this->assertCount( 1, $resources, - "Expected one resource but found ".count($resources) + "Expected one resource but found " . count($resources) ); - $this->assertEquals( + $this->assertSame( 'uploaded.txt', $resources[0]->getName(), - "Expected 'uploaded.txt' file but found ".$resources[0]->getName() + "Expected 'uploaded.txt' file but found " . $resources[0]->getName() ); $content = $this->getContentOfResource425Save($resources[0]); - $this->assertEquals( + $this->assertSame( 'some content', $content, "File content doesn't match" @@ -294,15 +290,15 @@ public function testUploadFileOverwritingExisting(): void $this->assertCount( 1, $resources, - "Expected one resource but found ".count($resources) + "Expected one resource but found " . count($resources) ); - $this->assertEquals( + $this->assertSame( 'uploaded.txt', $resources[0]->getName(), - "Expected 'uploaded.txt' file but found ".$resources[0]->getName() + "Expected 'uploaded.txt' file but found " . $resources[0]->getName() ); $content = $this->getContentOfResource425Save($resources[0]); - $this->assertEquals( + $this->assertSame( 'new content', $content, "File content doesn't match" @@ -328,15 +324,15 @@ public function testUploadFileToReceivedFolderShare(): void $this->assertCount( 1, $resources, - "Expected one resource but found ".count($resources) + "Expected one resource but found " . count($resources) ); - $this->assertEquals( + $this->assertSame( 'uploaded.txt', $resources[0]->getName(), - "Expected 'uploaded.txt' file but found ".$resources[0]->getName() + "Expected 'uploaded.txt' file but found " . $resources[0]->getName() ); $content = $this->getContentOfResource425Save($resources[0]); - $this->assertEquals( + $this->assertSame( 'some content', $content, "File content doesn't match" @@ -378,15 +374,15 @@ public function testUploadFileStream(): void $this->assertCount( 1, $resources, - "Expected one resource but found ".count($resources) + "Expected one resource but found " . count($resources) ); - $this->assertEquals( + $this->assertSame( 'uploaded.txt', $resources[0]->getName(), - "Expected 'uploaded.txt' file but found ".$resources[0]->getName() + "Expected 'uploaded.txt' file but found " . $resources[0]->getName() ); $content = $this->getContentOfResource425Save($resources[0]); - $this->assertEquals( + $this->assertSame( 'some content', $content, "File content doesn't match" @@ -397,7 +393,7 @@ public function testUploadFileStream(): void /** * @return array> */ - public static function resources() + public static function resources(): array { return [ ['somefile.txt','file'], @@ -411,14 +407,14 @@ public function testMoveResource(string $resourceName, string $type): void { $rootResources = $this->personalDrive->getResources(); - $isResourceMoved = $this->personalDrive->moveResource($resourceName, 'subfolder/'.$resourceName); + $isResourceMoved = $this->personalDrive->moveResource($resourceName, 'subfolder/' . $resourceName); $this->assertTrue($isResourceMoved, "couldn't move the resource"); $resourceInsideFolder = $this->personalDrive->getResources('/subfolder'); $this->assertCount( 1, $resourceInsideFolder, - "Expected one resources but found ".count($resourceInsideFolder) + "Expected one resources but found " . count($resourceInsideFolder) ); $rootResourcesAfterMove = $this->personalDrive->getResources(); @@ -433,8 +429,8 @@ public function testMoveResource(string $resourceName, string $type): void } if ($type === 'file') { - $fileContent = $this->personalDrive->getFile('subfolder/'.$resourceName); - $this->assertEquals( + $fileContent = $this->personalDrive->getFile('subfolder/' . $resourceName); + $this->assertSame( 'some content', $fileContent, "File content doesn't match" @@ -445,7 +441,7 @@ public function testMoveResource(string $resourceName, string $type): void /** * @return array> */ - public static function invalidResources() + public static function invalidResources(): array { return [ ['nonExistentFile.txt'], @@ -458,7 +454,7 @@ public static function invalidResources() public function testMoveNonExistentResource(string $invalidResources): void { $this->expectException(NotFoundException::class); - $this->personalDrive->moveResource($invalidResources, 'subfolder/'. $invalidResources); + $this->personalDrive->moveResource($invalidResources, 'subfolder/' . $invalidResources); } public function testGetRoles(): void @@ -480,13 +476,13 @@ public function testGetRolesOfDeletedResources(): void $resources = $this->personalDrive->getResources(); $newResource = null; foreach ($resources as $resource) { - if($resource->getName() === 'newResource.txt') { + if ($resource->getName() === 'newResource.txt') { $newResource = $resource; } } $this->personalDrive->deleteResource('/newResource.txt'); $this->expectException(NotFoundException::class); - if($newResource !== null) { + if ($newResource !== null) { $newResource->getRoles(); } } diff --git a/tests/integration/Owncloud/OcisPhpSdk/OcisTest.php b/tests/integration/Owncloud/OcisPhpSdk/OcisTest.php index 4d03c1cc..e4a67455 100644 --- a/tests/integration/Owncloud/OcisPhpSdk/OcisTest.php +++ b/tests/integration/Owncloud/OcisPhpSdk/OcisTest.php @@ -44,7 +44,7 @@ public function testGetMyDrives(): void $sharedResource = $resource; } } - if(empty($sharedResource)) { + if (empty($sharedResource)) { throw new \Error( "resource not found " ); @@ -53,13 +53,13 @@ public function testGetMyDrives(): void $viewerRole = null; $viewerRoleId = self::getPermissionsRoleIdByName('Viewer'); - foreach($sharedResource->getRoles() as $role) { - if($role->getId() === $viewerRoleId) { + foreach ($sharedResource->getRoles() as $role) { + if ($role->getId() === $viewerRoleId) { $viewerRole = $role; } } - if(empty($viewerRole)) { + if (empty($viewerRole)) { throw new \Error( "viewer role not found " ); @@ -79,7 +79,7 @@ public function testGetMyDrives(): void $drive->getName() . " drive of Marie matches with admin drive " ); if ($drive->getType() === DriveType::MOUNTPOINT) { - $this->assertEquals( + $this->assertSame( 'sharedAdminFolder', $drive->getName(), "Expected foldername to be 'sharedAdminFolder' but found " . $drive->getName() @@ -112,7 +112,7 @@ public function testGetAllDrives(): void } } - if(empty($sharedResource)) { + if (empty($sharedResource)) { throw new \Error( "resource not found " ); @@ -122,13 +122,13 @@ public function testGetAllDrives(): void $viewerRole = null; $viewerRoleId = self::getPermissionsRoleIdByName('Viewer'); - foreach($sharedResource->getRoles() as $role) { - if($role->getId() === $viewerRoleId) { + foreach ($sharedResource->getRoles() as $role) { + if ($role->getId() === $viewerRoleId) { $viewerRole = $role; } } - if(empty($viewerRole)) { + if (empty($viewerRole)) { throw new \Error( "viewer role not found " ); @@ -152,7 +152,7 @@ public function testGetAllDrives(): void "Expected drivetype to be either 'PROJECT' or 'PERSONAL' or 'VIRTUAL' but found " . print_r($drive->getType(), true) ); - if($drive->getType() === DriveType::PROJECT) { + if ($drive->getType() === DriveType::PROJECT) { $this->assertThat( $drive->getName(), $this->logicalOr( @@ -165,8 +165,8 @@ public function testGetAllDrives(): void . $drive->getName() ); } - if($drive->getType() === DriveType::MOUNTPOINT) { - $this->assertEquals( + if ($drive->getType() === DriveType::MOUNTPOINT) { + $this->assertSame( 'sharedAdminFolder', $drive->getName(), "Expected foldername to be 'sharedAdminFolder' but found " . $drive->getName() @@ -178,7 +178,7 @@ public function testGetAllDrives(): void /** * @return array> */ - public static function drivesType() + public static function drivesType(): array { return [ [DriveType::PROJECT], @@ -197,14 +197,14 @@ public function testGetAllDrivesType(DriveType $driveType): void $managementDrive = null; $sportDrive = null; - if($driveType === DriveType::PROJECT) { + if ($driveType === DriveType::PROJECT) { $sportDrive = $adminOcis->createDrive('Sport Project Drive'); $this->createdDrives[] = $sportDrive->getId(); $managementDrive = $adminOcis->createDrive('Management Project Drive'); $this->createdDrives[] = $managementDrive->getId(); } - if($driveType === DriveType::MOUNTPOINT) { + if ($driveType === DriveType::MOUNTPOINT) { $adminPersonalDrive = $adminOcis -> getMyDrives( DriveOrder::NAME, OrderDirection::ASC, @@ -220,7 +220,7 @@ public function testGetAllDrivesType(DriveType $driveType): void $sharedResource = $resource; } } - if(empty($sharedResource)) { + if (empty($sharedResource)) { throw new \Error( "resource not found " ); @@ -230,13 +230,13 @@ public function testGetAllDrivesType(DriveType $driveType): void $viewerRole = null; $viewerRoleId = self::getPermissionsRoleIdByName('Viewer'); - foreach($sharedResource->getRoles() as $role) { - if($role->getId() === $viewerRoleId) { + foreach ($sharedResource->getRoles() as $role) { + if ($role->getId() === $viewerRoleId) { $viewerRole = $role; } } - if(empty($viewerRole)) { + if (empty($viewerRole)) { throw new \Error( "viewer role not found " ); @@ -256,7 +256,7 @@ public function testGetAllDrivesType(DriveType $driveType): void "Expected Array to be an instance of " . Drive::class ); foreach ($drives as $drive) { - $this->assertEquals( + $this->assertSame( $drive->getType(), $driveType, "Drivetype mismatch" @@ -275,14 +275,14 @@ public function testGetAllDrivesType(DriveType $driveType): void ); } if ($drive->getType() === DriveType::MOUNTPOINT) { - $this->assertEquals( + $this->assertSame( 'sharedAdminFolder', $drive->getName(), "Expected drivename to be 'sharedAdminFolder' but found " . $drive->getName() ); } if ($drive->getType() === DriveType::VIRTUAL) { - $this->assertEquals( + $this->assertSame( 'Shares', $drive->getName(), "Expected drivename to be 'Shares' but found " . $drive->getName() @@ -302,18 +302,18 @@ public function testGetDriveById(): void $drive, "Expected class to be 'Drive' but found " . get_class($drive) ); - $this->assertEquals( + $this->assertSame( $drive->getId(), $sportDrive->getId(), "Expected driveid to be " . $drive->getId() . " but found " . $sportDrive->getId() ); - $this->assertEquals( + $this->assertSame( $drive->getName(), $sportDrive->getName(), "Expect drivename to be " . $drive->getName() . " but found " . $sportDrive->getName() ); - $this->assertEquals( + $this->assertSame( $drive->getType(), $sportDrive->getType(), "Drivetype mismatch" @@ -327,7 +327,7 @@ public function testGetDriveById(): void $this->markTestIncomplete( 'libre graph issue-149 sends broken quota object while creating drive' ); - // $this->assertEquals($sportDrive, $drive); + // $this->assertSame($sportDrive, $drive); } public function testCreateDrive(): void @@ -365,7 +365,7 @@ public function testCreateDriveNoPermissions(): void /** * @return array> */ - public static function invalidQuotaProvider() + public static function invalidQuotaProvider(): array { return [ [-1], @@ -440,7 +440,7 @@ public function testGetGroups(array $groupName): void $groupDisplayName = [$philosophyHatersGroup->getDisplayName(),$physicsLoversGroup->getDisplayName()]; $this->assertTrue( $groupDisplayName === [$groupName[0],$groupName[1]], - "Expected group displayname to be {$groupName[0]} and {$groupName[1]} but found " + "Expected group displayname to be $groupName[0] and $groupName[1] but found " . implode(' and ', $groupDisplayName) ); } @@ -499,7 +499,7 @@ public function testGetGroupSearch(string $searchText, array $groupDisplayName): "Group count doesn't match " ); for ($i = 0; $i < count($groups); $i++) { - $this->assertEquals( + $this->assertSame( $groupDisplayName[$i], $groups[$i]->getDisplayName(), "Expected group display name to be " . $groupDisplayName[$i] @@ -540,7 +540,7 @@ public function testGetGroupSort(OrderDirection $orderDirection, string $searchT "Expected group count to be " . count($resultGroups) . " but found " . count($groups) ); for ($i = 0; $i < count($groups); $i++) { - $this->assertEquals( + $this->assertSame( $resultGroups[$i], $groups[$i]->getDisplayName(), "Expected group display name to be " . $resultGroups[$i] @@ -557,8 +557,8 @@ public function testDeleteGroupById(): void $ocis = $this->getOcis('admin', 'admin'); $ocis->createGroup("philosophyhaters", "philosophy haters group"); $physicsLoversGroup = $ocis->createGroup("physicslovers", "physics lover group"); - foreach($ocis->getGroups() as $group) { - if($group->getDisplayName() === "philosophyhaters") { + foreach ($ocis->getGroups() as $group) { + if ($group->getDisplayName() === "philosophyhaters") { $ocis->deleteGroupByID($group->getId()); } } @@ -567,7 +567,7 @@ public function testDeleteGroupById(): void $ocis->getGroups(), "Expected group count to be 1 but found " . count($ocis->getGroups()) ); - $this->assertEquals( + $this->assertSame( "physicslovers", $ocis->getGroups()[0]->getDisplayName(), "Expected group display name to be 'physicslovers' but found " . $ocis->getGroups()[0]->getDisplayName() diff --git a/tests/integration/Owncloud/OcisPhpSdk/ResourceInviteTest.php b/tests/integration/Owncloud/OcisPhpSdk/ResourceInviteTest.php index fbc6de48..152bb8d2 100644 --- a/tests/integration/Owncloud/OcisPhpSdk/ResourceInviteTest.php +++ b/tests/integration/Owncloud/OcisPhpSdk/ResourceInviteTest.php @@ -39,9 +39,6 @@ public function setUp(): void $this->personalDrive->createFolder('folder-to-share'); $this->createdResources[$this->personalDrive->getId()][] = 'folder-to-share'; $resources = $this->personalDrive->getResources(); - /** - * @var OcisResource $resource - */ foreach ($resources as $resource) { if ($resource->getName() === 'to-share-test.txt') { $this->fileToShare = $resource; @@ -54,9 +51,6 @@ public function setUp(): void $this->einstein = $this->ocis->getUsers('einstein')[0]; $this->marie = $this->ocis->getUsers('marie')[0]; - /** - * @var SharingRole $role - */ foreach ($this->fileToShare->getRoles() as $role) { if ($role->getId() === self::getPermissionsRoleIdByName('Viewer')) { $this->viewerRole = $role; @@ -333,16 +327,10 @@ public function testGetReceiversOfShareReturnedBySharedByMe(): void public function testInviteUserToAReceivedShare(): void { $this->fileToShare->invite($this->einstein, $this->editorRole); - /** - * @var ShareReceived $receivedShare - */ $receivedShare = $this->getSharedWithMeWaitTillShareIsAccepted($this->einsteinOcis)[0]; $resource = $this->einsteinOcis->getResourceById($receivedShare->getRemoteItemId()); $resource->invite($this->marie, $this->viewerRole); - /** - * @var ShareReceived $receivedShare - */ $receivedShare = $this->getSharedWithMeWaitTillShareIsAccepted($this->marieOcis)[0]; $this->assertSame( 'to-share-test.txt', diff --git a/tests/integration/Owncloud/OcisPhpSdk/ResourceShareLinkTest.php b/tests/integration/Owncloud/OcisPhpSdk/ResourceShareLinkTest.php index 7a073c24..f519bd97 100644 --- a/tests/integration/Owncloud/OcisPhpSdk/ResourceShareLinkTest.php +++ b/tests/integration/Owncloud/OcisPhpSdk/ResourceShareLinkTest.php @@ -26,9 +26,6 @@ public function setUp(): void $personalDrive->createFolder('folder-to-share'); $this->createdResources[$personalDrive->getId()][] = 'folder-to-share'; $resources = $personalDrive->getResources(); - /** - * @var OcisResource $resource - */ foreach ($resources as $resource) { if ($resource->getName() === 'to-share-test.txt') { $this->fileToShare = $resource; @@ -182,12 +179,12 @@ public function testSetExpiration(): void $this->assertEquals( $expectedExpirationDate, $link->getExpiration(), - "Expiration DateTime mismatch" + "Expiration DateTime mismatch with original sharing link" ); $this->assertEquals( $expectedExpirationDate, $linkFromSharedByMe->getExpiration(), - "Expiration DateTime mismatch" + "Expiration DateTime mismatch with link from shared-by-me" ); } diff --git a/tests/integration/Owncloud/OcisPhpSdk/ShareCreatedModifyTest.php b/tests/integration/Owncloud/OcisPhpSdk/ShareCreatedModifyTest.php index 68735576..c789a6d3 100644 --- a/tests/integration/Owncloud/OcisPhpSdk/ShareCreatedModifyTest.php +++ b/tests/integration/Owncloud/OcisPhpSdk/ShareCreatedModifyTest.php @@ -37,9 +37,6 @@ public function setUp(): void $this->einstein = $this->ocis->getUsers('einstein')[0]; $this->marie = $this->ocis->getUsers('marie')[0]; - /** - * @var SharingRole $role - */ foreach ($this->fileToShare->getRoles() as $role) { if ($role->getDisplayName() === 'Viewer') { $this->viewerRole = $role; diff --git a/tests/integration/Owncloud/OcisPhpSdk/ShareGetShareByMeTest.php b/tests/integration/Owncloud/OcisPhpSdk/ShareGetShareByMeTest.php index 7f96632a..bfdfc2c0 100644 --- a/tests/integration/Owncloud/OcisPhpSdk/ShareGetShareByMeTest.php +++ b/tests/integration/Owncloud/OcisPhpSdk/ShareGetShareByMeTest.php @@ -62,7 +62,7 @@ public function testGetShareByMe(): void "Expected class " . ShareCreated::class . " but got " . get_class($myShare[0]) ); - $this->assertEquals( + $this->assertSame( 'Albert Einstein', $myShare[0]->getReceiver()->getDisplayName(), "Expected receiver display name to be 'Albert Einstein' but found " . $myShare[0]->getReceiver()->getDisplayName() @@ -119,17 +119,17 @@ public function testGetShareAndShareLinkByMe(): void $this->assertInstanceOf( ShareCreated::class, $myShares[0], - "Expected class ".ShareCreated::class + "Expected class " . ShareCreated::class . " but got " . get_class($myShares[0]) ); $this->assertInstanceOf( ShareLink::class, $myShares[1], - "Expected class ".ShareLink::class + "Expected class " . ShareLink::class . " but got " . get_class($myShares[1]) ); - foreach($myShares as $myshare) { - $this->assertEquals( + foreach ($myShares as $myshare) { + $this->assertSame( $this->sharedResource->getId(), $myshare->getResourceId(), "ResourceId doesn't match with shared resourceId" diff --git a/tests/integration/Owncloud/OcisPhpSdk/ShareGetSharedWithMeTest.php b/tests/integration/Owncloud/OcisPhpSdk/ShareGetSharedWithMeTest.php index e422cede..7eb9a56d 100644 --- a/tests/integration/Owncloud/OcisPhpSdk/ShareGetSharedWithMeTest.php +++ b/tests/integration/Owncloud/OcisPhpSdk/ShareGetSharedWithMeTest.php @@ -59,9 +59,6 @@ public function setUp(): void public function testGetAttributesOfReceivedShare(): void { $this->fileToShare->invite($this->einstein, $this->editorRole); - /** - * @var ShareReceived $receivedShare - */ $receivedShare = $this->getSharedWithMeWaitTillShareIsAccepted($this->einsteinOcis)[0]; $this->assertInstanceOf( ShareReceived::class, @@ -77,10 +74,10 @@ public function testGetAttributesOfReceivedShare(): void $this->assertNotNull($receivedShare->getId(), "Expected received share id to not be null"); $this->assertGreaterThanOrEqual( 1, - strlen((string)$receivedShare->getId()), + strlen($receivedShare->getId()), " The length of received share id to be greater than 1 " ); - $this->assertEquals( + $this->assertSame( $this->fileToShare->getName(), $receivedShare->getName(), "Expected shared file to be " . $this->fileToShare->getName() . " but found " . $receivedShare->getName() @@ -107,7 +104,7 @@ public function testGetAttributesOfReceivedShare(): void 120, "Expected Shared resource was last modified within 120 seconds of the current time" ); - $this->assertStringContainsString( + $this->assertSame( 'Admin', $receivedShare->getCreatedByDisplayName(), "Expected owner name to be 'Admin' but found " . $receivedShare->getCreatedByDisplayName() @@ -115,7 +112,7 @@ public function testGetAttributesOfReceivedShare(): void $this->assertGreaterThanOrEqual( 1, strlen($receivedShare->getCreatedByUserId()), - "Expected the length of ownerId of receive share to be greater than 1" + "Expected the length of ownerId of receive share to be greater than or equal to 1" ); } @@ -130,7 +127,7 @@ public function testReceiveMultipleShares(): void $this->fileToShare->invite($philosophyHatersGroup, $this->editorRole); $this->folderToShare->invite($this->einstein, $this->editorRole); $receivedShares = $this->getSharedWithMeWaitTillShareIsAccepted($this->einsteinOcis); - foreach($receivedShares as $receivedShare) { + foreach ($receivedShares as $receivedShare) { $this->assertInstanceOf( ShareReceived::class, $receivedShare, @@ -150,7 +147,7 @@ public function testReceiveMultipleShares(): void $this->equalTo($this->fileToShare->getName()), $this->equalTo($this->folderToShare->getName()) ), - "Expected shared resource name to be " . $this->fileToShare->getName() . " or " . $this->folderToShare->getName(). + "Expected shared resource name to be " . $this->fileToShare->getName() . " or " . $this->folderToShare->getName() . " but found " . $receivedShares[$i]->getName() ); $this->assertThat( @@ -159,8 +156,8 @@ public function testReceiveMultipleShares(): void $this->equalTo($this->fileToShare->getId()), $this->equalTo($this->folderToShare->getId()) ), - "Expected shared resource Id to be " . $this->fileToShare->getId() . " or " . $this->folderToShare->getId() - . " but found " . $receivedShares[$i]->getRemoteItemId() + "Expected shared resource Id to be " . $this->fileToShare->getId() . " or " . $this->folderToShare->getId() . + " but found " . $receivedShares[$i]->getRemoteItemId() ); } @@ -177,7 +174,7 @@ public function testReceiveSameShareMultipleTimes(): void $this->fileToShare->invite($philosophyHatersGroup, $this->editorRole); $this->fileToShare->invite($this->einstein, $this->editorRole); $receivedShares = $this->getSharedWithMeWaitTillShareIsAccepted($this->einsteinOcis); - foreach($receivedShares as $receivedShare) { + foreach ($receivedShares as $receivedShare) { $this->assertInstanceOf( ShareReceived::class, $receivedShare, @@ -220,9 +217,6 @@ public function testCompareSharedWithMeAndShareDrive(): void $receivedShares = $this->getSharedWithMeWaitTillShareIsAccepted($this->einsteinOcis); - /** - * @var Drive $shareDrive - */ $shareDrive = $this->einsteinOcis->getMyDrives( DriveOrder::NAME, OrderDirection::ASC, @@ -240,14 +234,8 @@ public function testCompareSharedWithMeAndShareDrive(): void $resourcesInShareJail, "Expected two receive shares but found " . count($resourcesInShareJail) ); - /** - * @var OcisResource $resource - */ foreach ($resourcesInShareJail as $resource) { $foundMatchingShare = false; - /** - * @var ShareReceived $share - */ foreach ($receivedShares as $share) { if ( $share->getName() === $resource->getName() diff --git a/tests/integration/Owncloud/OcisPhpSdk/ShareTestGetSharedWithMeNotSyncedSharesTest.php b/tests/integration/Owncloud/OcisPhpSdk/ShareTestGetSharedWithMeNotSyncedSharesTest.php index 4bf1ede5..1f0c6890 100644 --- a/tests/integration/Owncloud/OcisPhpSdk/ShareTestGetSharedWithMeNotSyncedSharesTest.php +++ b/tests/integration/Owncloud/OcisPhpSdk/ShareTestGetSharedWithMeNotSyncedSharesTest.php @@ -31,9 +31,6 @@ public function setUp(): void $this->fileToShare = $this->personalDrive->getResources()[0]; $this->einstein = $this->ocis->getUsers('einstein')[0]; - /** - * @var SharingRole $role - */ foreach ($this->fileToShare->getRoles() as $role) { if ($role->getDisplayName() === 'Viewer') { $this->viewerRole = $role; @@ -55,9 +52,6 @@ public static function tearDownAfterClass(): void public function testGetAttributesOfReceivedButNotAcceptedShare(): void { $this->fileToShare->invite($this->einstein, $this->viewerRole); - /** - * @var ShareReceived $receivedShare - */ $receivedShare = $this->einsteinOcis->getSharedWithMe()[0]; $this->assertInstanceOf( ShareReceived::class, @@ -81,7 +75,7 @@ public function testGetAttributesOfReceivedButNotAcceptedShare(): void "Expected received share to be client synchronized, but found not synced" ); $this->assertMatchesRegularExpression( - '/^' . $this->getUUIDv4Regex() . '\$' . $this->getUUIDv4Regex(). '!' . $this->getUUIDv4Regex() . ':' . $this->getUUIDv4Regex() .':' . $this->getUUIDv4Regex(). '$/i', + '/^' . $this->getUUIDv4Regex() . '\$' . $this->getUUIDv4Regex() . '!' . $this->getUUIDv4Regex() . ':' . $this->getUUIDv4Regex() . ':' . $this->getUUIDv4Regex() . '$/i', $receivedShare->getId(), "Shareid doesn't match the expected format" ); @@ -91,7 +85,7 @@ public function testGetAttributesOfReceivedButNotAcceptedShare(): void "The file-id of the remote item in the receive share is different to the id of the shared file" ); $this->assertMatchesRegularExpression( - "/^\"[a-f0-9:\.]{1,32}\"$/", + "/^\"[a-f0-9:.]{1,32}\"$/", $receivedShare->getEtag(), "Resource Etag doesn't match the expected format" ); diff --git a/tests/integration/Owncloud/OcisPhpSdk/UsersTest.php b/tests/integration/Owncloud/OcisPhpSdk/UsersTest.php index c32ed3f5..43fc7b54 100644 --- a/tests/integration/Owncloud/OcisPhpSdk/UsersTest.php +++ b/tests/integration/Owncloud/OcisPhpSdk/UsersTest.php @@ -44,7 +44,7 @@ public function testGetUsersByNormalUser(): void count($users), "Expected at least 1 user, but found " . count($users) ); - $this->assertEquals( + $this->assertSame( 'Marie Curie', $users[0]->getDisplayName(), "Username should be 'Marie Curie' but found " . $users[0]->getDisplayName() @@ -70,7 +70,7 @@ public function testSearchUsers(): void count($users), "Expected at least 1 user, but found " . count($users) ); - $this->assertEquals( + $this->assertSame( 'Albert Einstein', $users[0]->getDisplayName(), "Username should be 'Albert Einstein' but found " . $users[0]->getDisplayName()