Skip to content

Commit

Permalink
Merge pull request #210 from owncloud/adjust-integration-tests
Browse files Browse the repository at this point in the history
test: adjust integration tests
  • Loading branch information
individual-it authored Apr 18, 2024
2 parents c67b263 + 10b9d4d commit 482b54b
Show file tree
Hide file tree
Showing 13 changed files with 131 additions and 174 deletions.
6 changes: 3 additions & 3 deletions tests/integration/Owncloud/OcisPhpSdk/DriveTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
34 changes: 17 additions & 17 deletions tests/integration/Owncloud/OcisPhpSdk/GroupsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
);
}
Expand All @@ -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()
);
}

Expand All @@ -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);
}
}
Expand Down Expand Up @@ -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()
);

}
Expand All @@ -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());
Expand Down
9 changes: 3 additions & 6 deletions tests/integration/Owncloud/OcisPhpSdk/NotificationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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"
Expand Down
18 changes: 9 additions & 9 deletions tests/integration/Owncloud/OcisPhpSdk/OcisPhpSdkTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,20 @@ class OcisPhpSdkTestCase extends TestCase
private ?string $tokenUrl = null;
private ?Client $guzzleClient = null;
/**
* @var array <string>
* @var array<string>
*/
protected $createdDrives = [];
protected array $createdDrives = [];
/**
* list of files and folders that were created during the tests
* currently only for the personal drive
* @var array <string, array<string>> driveId[] => resourcePath
* @var array<string, array<string>> 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
{
Expand All @@ -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
}

Expand All @@ -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
}
}
Expand Down Expand Up @@ -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');
Expand Down
Loading

0 comments on commit 482b54b

Please sign in to comment.