Integration tests for search
Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
use Behat\Behat\Context\Context;
|
||||
use Behat\Behat\Hook\Scope\BeforeScenarioScope;
|
||||
use Behat\Gherkin\Node\TableNode;
|
||||
use PHPUnit\Framework\Assert;
|
||||
|
||||
@@ -16,25 +17,35 @@ class BoardContext implements Context {
|
||||
/** @var array last card response */
|
||||
private $card = null;
|
||||
|
||||
/** @var ServerContext */
|
||||
private $serverContext;
|
||||
|
||||
/** @BeforeScenario */
|
||||
public function gatherContexts(BeforeScenarioScope $scope) {
|
||||
$environment = $scope->getEnvironment();
|
||||
|
||||
$this->serverContext = $environment->getContext('ServerContext');
|
||||
}
|
||||
|
||||
/**
|
||||
* @Given /^creates a board named "([^"]*)" with color "([^"]*)"$/
|
||||
*/
|
||||
public function createsABoardNamedWithColor($title, $color) {
|
||||
$this->sendJSONrequest('POST', '/index.php/apps/deck/boards', [
|
||||
$this->requestContext->sendJSONrequest('POST', '/index.php/apps/deck/boards', [
|
||||
'title' => $title,
|
||||
'color' => $color
|
||||
]);
|
||||
$this->response->getBody()->seek(0);
|
||||
$this->board = json_decode((string)$this->response->getBody(), true);
|
||||
$this->getResponse()->getBody()->seek(0);
|
||||
$this->board = json_decode((string)$this->getResponse()->getBody(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @When /^fetches the board named "([^"]*)"$/
|
||||
*/
|
||||
public function fetchesTheBoardNamed($boardName) {
|
||||
$this->sendJSONrequest('GET', '/index.php/apps/deck/boards/' . $this->board['id'], []);
|
||||
$this->response->getBody()->seek(0);
|
||||
$this->board = json_decode((string)$this->response->getBody(), true);
|
||||
$this->requestContext->sendJSONrequest('GET', '/index.php/apps/deck/boards/' . $this->board['id'], []);
|
||||
$this->getResponse()->getBody()->seek(0);
|
||||
$this->board = json_decode((string)$this->getResponse()->getBody(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -48,7 +59,7 @@ class BoardContext implements Context {
|
||||
];
|
||||
$tableRows = isset($permissions) ? $permissions->getRowsHash() : [];
|
||||
$result = array_merge($defaults, $tableRows);
|
||||
$this->sendJSONrequest('POST', '/index.php/apps/deck/boards/' . $this->board['id'] . '/acl', [
|
||||
$this->requestContext->sendJSONrequest('POST', '/index.php/apps/deck/boards/' . $this->board['id'] . '/acl', [
|
||||
'type' => 0,
|
||||
'participant' => $user,
|
||||
'permissionEdit' => $result['permissionEdit'] === '1',
|
||||
@@ -68,7 +79,7 @@ class BoardContext implements Context {
|
||||
];
|
||||
$tableRows = isset($permissions) ? $permissions->getRowsHash() : [];
|
||||
$result = array_merge($defaults, $tableRows);
|
||||
$this->sendJSONrequest('POST', '/index.php/apps/deck/boards/' . $this->board['id'] . '/acl', [
|
||||
$this->requestContext->sendJSONrequest('POST', '/index.php/apps/deck/boards/' . $this->board['id'] . '/acl', [
|
||||
'type' => 1,
|
||||
'participant' => $group,
|
||||
'permissionEdit' => $result['permissionEdit'] === '1',
|
||||
@@ -82,38 +93,38 @@ class BoardContext implements Context {
|
||||
* @When /^fetching the board list$/
|
||||
*/
|
||||
public function fetchingTheBoardList() {
|
||||
$this->sendJSONrequest('GET', '/index.php/apps/deck/boards');
|
||||
$this->requestContext->sendJSONrequest('GET', '/index.php/apps/deck/boards');
|
||||
}
|
||||
|
||||
/**
|
||||
* @When /^fetching the board with id "([^"]*)"$/
|
||||
*/
|
||||
public function fetchingTheBoardWithId($id) {
|
||||
$this->sendJSONrequest('GET', '/index.php/apps/deck/boards/' . $id);
|
||||
$this->requestContext->sendJSONrequest('GET', '/index.php/apps/deck/boards/' . $id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Given /^create a stack named "([^"]*)"$/
|
||||
*/
|
||||
public function createAStackNamed($name) {
|
||||
$this->sendJSONrequest('POST', '/index.php/apps/deck/stacks', [
|
||||
$this->requestContext->sendJSONrequest('POST', '/index.php/apps/deck/stacks', [
|
||||
'title' => $name,
|
||||
'boardId' => $this->board['id']
|
||||
]);
|
||||
$this->response->getBody()->seek(0);
|
||||
$this->stack = json_decode((string)$this->response->getBody(), true);
|
||||
$this->requestContext->getResponse()->getBody()->seek(0);
|
||||
$this->stack = json_decode((string)$this->getResponse()->getBody(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Given /^create a card named "([^"]*)"$/
|
||||
*/
|
||||
public function createACardNamed($name) {
|
||||
$this->sendJSONrequest('POST', '/index.php/apps/deck/cards', [
|
||||
$this->requestContext->sendJSONrequest('POST', '/index.php/apps/deck/cards', [
|
||||
'title' => $name,
|
||||
'stackId' => $this->stack['id']
|
||||
]);
|
||||
$this->response->getBody()->seek(0);
|
||||
$this->card = json_decode((string)$this->response->getBody(), true);
|
||||
$this->requestContext->getResponse()->getBody()->seek(0);
|
||||
$this->card = json_decode((string)$this->getResponse()->getBody(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -151,4 +162,70 @@ class BoardContext implements Context {
|
||||
]);
|
||||
$this->serverContext->creatingShare($table);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Given /^set the description to "([^"]*)"$/
|
||||
*/
|
||||
public function setTheDescriptionTo($description) {
|
||||
$this->requestContext->sendJSONrequest('PUT', '/index.php/apps/deck/cards/' . $this->card['id'], array_merge(
|
||||
$this->card,
|
||||
['description' => $description]
|
||||
));
|
||||
$this->requestContext->getResponse()->getBody()->seek(0);
|
||||
$this->card = json_decode((string)$this->getResponse()->getBody(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Given /^set the card attribute "([^"]*)" to "([^"]*)"$/
|
||||
*/
|
||||
public function setCardAttribute($attribute, $value) {
|
||||
$this->requestContext->sendJSONrequest('PUT', '/index.php/apps/deck/cards/' . $this->card['id'], array_merge(
|
||||
$this->card,
|
||||
[$attribute => $value]
|
||||
));
|
||||
$this->requestContext->getResponse()->getBody()->seek(0);
|
||||
$this->card = json_decode((string)$this->getResponse()->getBody(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Given /^set the card duedate to "([^"]*)"$/
|
||||
*/
|
||||
public function setTheCardDuedateTo($arg1) {
|
||||
$date = new DateTime($arg1);
|
||||
$this->setCardAttribute('duedate', $date->format(DateTimeInterface::ATOM));
|
||||
}
|
||||
|
||||
/**
|
||||
* @Given /^assign the card to the user "([^"]*)"$/
|
||||
*/
|
||||
public function assignTheCardToTheUser($user) {
|
||||
$this->assignToCard($user, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Given /^assign the card to the group "([^"]*)"$/
|
||||
*/
|
||||
public function assignTheCardToTheGroup($user) {
|
||||
$this->assignToCard($user, 1);
|
||||
}
|
||||
|
||||
private function assignToCard($participant, $type) {
|
||||
$this->requestContext->sendJSONrequest('POST', '/index.php/apps/deck/cards/' . $this->card['id'] .'/assign', [
|
||||
'userId' => $participant,
|
||||
'type' => $type
|
||||
]);
|
||||
$this->requestContext->getResponse()->getBody()->seek(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Given /^assign the tag "([^"]*)" to the card$/
|
||||
*/
|
||||
public function assignTheTagToTheCard($tag) {
|
||||
$filteredLabels = array_filter($this->board['labels'], function ($label) use ($tag) {
|
||||
return $label['title'] === $tag;
|
||||
});
|
||||
$label = array_shift($filteredLabels);
|
||||
$this->requestContext->sendJSONrequest('POST', '/index.php/apps/deck/cards/' . $this->card['id'] .'/label/' . $label['id']);
|
||||
$this->requestContext->getResponse()->getBody()->seek(0);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user