Skip to content

Commit

Permalink
tests: Fix missing behat context methods
Browse files Browse the repository at this point in the history
Signed-off-by: Julius Härtl <[email protected]>
  • Loading branch information
juliusknorr committed Jan 9, 2024
1 parent 632871a commit 8425a88
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 4 deletions.
1 change: 0 additions & 1 deletion lib/Service/PermissionService.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ public function checkPermission(?IPermissionMapper $mapper, $id, int $permission

$permissions = $this->getPermissions($boardId, $userId);
if ($permissions[$permission] === true) {

if (!$allowDeletedCard && $mapper instanceof CardMapper) {
$card = $mapper->find($id);
if ($card->getDeletedAt() > 0) {
Expand Down
2 changes: 0 additions & 2 deletions tests/integration/features/bootstrap/BoardContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,4 @@ public function getActivitiesForTheLastCard() {
public function theFetchedActivitiesShouldHaveEntries($count) {
Assert::assertEquals($count, count($this->activities ?? []));
}


}
1 change: 0 additions & 1 deletion tests/integration/features/bootstrap/CommentContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,4 @@ public function deleteTheCommentOnTheCard() {
$card = $this->boardContext->getLastUsedCard();
$this->requestContext->sendOCSRequest('DELETE', '/apps/deck/api/v1.0/cards/' . $card['id'] . '/comments/'. $this->lastComment['id']);
}

}
25 changes: 25 additions & 0 deletions tests/integration/features/bootstrap/RequestContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,4 +166,29 @@ public function getResponseBodyFromJson() {
$this->getResponse()->getBody()->seek(0);
return json_decode((string)$this->getResponse()->getBody(), true);
}

/**
* @Given /^the response should be a list of objects$/
*/
public function theResponseShouldBeAListOfObjects() {
$jsonResponse = $this->getResponseBodyFromJson();
Assert::assertEquals(array_keys($jsonResponse), range(0, count($jsonResponse) - 1));
}

/**
* @When /^the response should contain an element with the properties$/
*/
public function responseContainsElement(TableNode $element) {
$json = $this->getResponseBodyFromJson();
$found = array_filter($json, function ($board) use ($element) {
foreach ($element as $row) {
if ($row['value'] !== $board[$row['property']]) {
return false;
}
}

return true;
});
Assert::assertEquals(1, count($found));
}
}

0 comments on commit 8425a88

Please sign in to comment.