Skip to content

Commit

Permalink
Merge pull request #37310 from owncloud/use-assertContainsEquals
Browse files Browse the repository at this point in the history
[Tests-Only] Use assertContainsEquals to compare status codes that could be in string or int form
  • Loading branch information
phil-davis authored Apr 27, 2020
2 parents 245251f + b13344d commit 0559c10
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 21 deletions.
2 changes: 1 addition & 1 deletion tests/acceptance/features/bootstrap/FeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -1221,7 +1221,7 @@ public function theHTTPStatusCodeShouldBe($expectedStatusCode, $message = "") {
$message = "HTTP status code $actualStatusCode is not one of the expected values";
}

Assert::assertContains(
Assert::assertContainsEquals(
$actualStatusCode, $expectedStatusCode,
$message
);
Expand Down
2 changes: 1 addition & 1 deletion tests/acceptance/features/bootstrap/OCSContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ public function theOCSStatusCodeShouldBe($statusCode, $message = "") {
$this->featureContext->getResponse()
);
if (\is_array($statusCode)) {
Assert::assertContains(
Assert::assertContainsEquals(
$responseStatusCode, $statusCode,
$message
);
Expand Down
12 changes: 6 additions & 6 deletions tests/acceptance/features/bootstrap/Provisioning.php
Original file line number Diff line number Diff line change
Expand Up @@ -3309,8 +3309,8 @@ public function theUsersShouldBe($usersList) {
$users = $usersList->getRows();
$usersSimplified = $this->simplifyArray($users);
$respondedArray = $this->getArrayOfUsersResponded($this->response);
Assert::assertEquals(
$usersSimplified, $respondedArray, "", 0.0, 10, true
Assert::assertEqualsCanonicalizing(
$usersSimplified, $respondedArray
);
}

Expand All @@ -3326,8 +3326,8 @@ public function theGroupsShouldBe($groupsList) {
$groups = $groupsList->getRows();
$groupsSimplified = $this->simplifyArray($groups);
$respondedArray = $this->getArrayOfGroupsResponded($this->response);
Assert::assertEquals(
$groupsSimplified, $respondedArray, "", 0.0, 10, true
Assert::assertEqualsCanonicalizing(
$groupsSimplified, $respondedArray
);
}

Expand Down Expand Up @@ -3377,8 +3377,8 @@ public function checkSubadminGroupsOrUsersTable($groupsOrUsersList) {
$tableRows = $groupsOrUsersList->getRows();
$simplifiedTableRows = $this->simplifyArray($tableRows);
$respondedArray = $this->getArrayOfSubadminsResponded($this->response);
Assert::assertEquals(
$simplifiedTableRows, $respondedArray, "", 0.0, 10, true
Assert::assertEqualsCanonicalizing(
$simplifiedTableRows, $respondedArray
);
}

Expand Down
28 changes: 15 additions & 13 deletions tests/acceptance/features/bootstrap/Sharing.php
Original file line number Diff line number Diff line change
Expand Up @@ -2033,12 +2033,19 @@ function (&$value, $key) {
);
}

// check if attributes received from table is subset of actualAttributes
Assert::assertArraySubset(
$attributes,
$actualAttributesArray,
"The additional sharing attributes did not include the expected attributes. See the differences below."
);
// check if the expected attributes received from table match actualAttributes
foreach (['scope', 'key', 'enabled'] as $key) {
Assert::assertArrayHasKey(
$key,
$actualAttributesArray,
"the additional sharing attributes in the last response did not have key '$key'"
);
Assert::assertEquals(
$attributes[$key],
$actualAttributesArray[$key],
"the additional sharing attribute '$key' had value " . $actualAttributesArray[$key] . " but was expected to have value " . $actualAttributesArray[$key]
);
}
}

/**
Expand Down Expand Up @@ -2418,13 +2425,8 @@ public function assertSharesOfUserAreInState($user, $state, TableNode $table) {
$row['path'] = "/" . \trim($row['path'], "/");
foreach ($usersShares as $share) {
try {
Assert::assertArraySubset(
$row,
$share,
"Expected '"
. \ implode(', ', $row)
. "' was not included in the share of the user. See the difference below"
);
Assert::assertArrayHasKey('path', $share);
Assert::assertEquals($row['path'], $share['path']);
$found = true;
break;
} catch (PHPUnit\Framework\ExpectationFailedException $e) {
Expand Down

0 comments on commit 0559c10

Please sign in to comment.