Skip to content

Commit 609a7b2

Browse files
committed
Integration tests
Signed-off-by: Julius Härtl <jus@bitgrid.net>
1 parent db2ceae commit 609a7b2

11 files changed

Lines changed: 438 additions & 206 deletions

File tree

tests/data/test.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Hello world

tests/integration/config/behat.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ default:
44
paths:
55
- '%paths.base%/../features/'
66
contexts:
7-
- FeatureContext:
7+
- ServerContext:
88
baseUrl: http://localhost:8080/index.php/ocs/
99
admin:
1010
- admin
1111
- admin
12-
regular_user_password: 123456
12+
regular_user_password: 123456
13+
- BoardContext:
14+
baseUrl: http://localhost:8080/

tests/integration/features/acl.feature

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,36 @@ Feature: acl
1010
And group "group1" exists
1111
Given user "user1" belongs to group "group1"
1212

13-
Scenario: Request the main frontend page
14-
Given Logging in using web as "user0"
15-
When Sending a "GET" to "/index.php/apps/deck" without requesttoken
16-
Then the HTTP status code should be "200"
17-
1813
Scenario: Fetch the board list
1914
Given Logging in using web as "user0"
20-
When Sending a "GET" to "/index.php/apps/deck/boards" with requesttoken
21-
Then the HTTP status code should be "200"
22-
And the Content-Type should be "application/json; charset=utf-8"
15+
When fetching the board list
16+
Then the response should have a status code "200"
17+
And the response Content-Type should be "application/json; charset=utf-8"
2318

2419
Scenario: Fetch board details of owned board
2520
Given Logging in using web as "admin"
2621
And creates a board named "MyPrivateAdminBoard" with color "fafafa"
27-
When "admin" fetches the board named "MyPrivateAdminBoard"
28-
Then the HTTP status code should be "200"
29-
And the Content-Type should be "application/json; charset=utf-8"
22+
When fetches the board named "MyPrivateAdminBoard"
23+
Then the response should have a status code "200"
24+
And the response Content-Type should be "application/json; charset=utf-8"
3025

3126
Scenario: Fetch board details of an other users board
3227
Given Logging in using web as "admin"
3328
And creates a board named "MyPrivateAdminBoard" with color "fafafa"
34-
When "user0" fetches the board named "MyPrivateAdminBoard"
35-
Then the HTTP status code should be "403"
36-
And the Content-Type should be "application/json; charset=utf-8"
29+
Given Logging in using web as "user0"
30+
When fetches the board named "MyPrivateAdminBoard"
31+
Then the response should have a status code "403"
32+
And the response Content-Type should be "application/json; charset=utf-8"
33+
34+
Scenario: Share a board
35+
Given Logging in using web as "user0"
36+
And creates a board named "Shared board" with color "fafafa"
37+
And shares the board with user "user1"
38+
Then the HTTP status code should be "200"
39+
Given Logging in using web as "user1"
40+
When fetches the board named "Shared board"
41+
And the current user should have read permissions on the board
42+
And the current user should have write permissions on the board
43+
And the current user should have share permissions on the board
44+
And the current user should have manage permissions on the board
45+
Then the HTTP status code should be "200"
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
<?php
2+
3+
use Behat\Behat\Context\Context;
4+
use Behat\Gherkin\Node\TableNode;
5+
use GuzzleHttp\Client;
6+
use Behat\Gherkin\Node\PyStringNode;
7+
use GuzzleHttp\Exception\ClientException;
8+
use PHPUnit\Framework\Assert;
9+
10+
require_once __DIR__ . '/../../vendor/autoload.php';
11+
12+
class BoardContext implements Context {
13+
use RequestTrait;
14+
15+
/** @var array Last board response */
16+
private $board = null;
17+
/** @var array last stack response */
18+
private $stack = null;
19+
/** @var array last card response */
20+
private $card = null;
21+
22+
/**
23+
* @Given /^creates a board named "([^"]*)" with color "([^"]*)"$/
24+
*/
25+
public function createsABoardNamedWithColor($title, $color) {
26+
$this->sendJSONrequest('POST', '/index.php/apps/deck/boards', [
27+
'title' => $title,
28+
'color' => $color
29+
]);
30+
$this->response->getBody()->seek(0);
31+
$this->board = json_decode((string)$this->response->getBody(), true);
32+
33+
}
34+
35+
/**
36+
* @When /^fetches the board named "([^"]*)"$/
37+
*/
38+
public function fetchesTheBoardNamed($boardName) {
39+
$this->sendJSONrequest('GET', '/index.php/apps/deck/boards/' . $this->board['id'], []);
40+
$this->response->getBody()->seek(0);
41+
$this->board = json_decode((string)$this->response->getBody(), true);
42+
}
43+
44+
/**
45+
* @When shares the board with user :user
46+
*/
47+
public function sharesTheBoardWithUser($user)
48+
{
49+
$this->sendJSONrequest('POST', '/index.php/apps/deck/boards/' . $this->board['id'] . '/acl', [
50+
'type' => 0,
51+
'participant' => $user,
52+
'permissionEdit' => true,
53+
'permissionShare' => true,
54+
'permissionManage' => true,
55+
]);
56+
}
57+
58+
59+
/**
60+
* @When /^fetching the board list$/
61+
*/
62+
public function fetchingTheBoardList() {
63+
$this->sendJSONrequest('GET', '/index.php/apps/deck/boards');
64+
}
65+
66+
/**
67+
* @When /^fetching the board with id "([^"]*)"$/
68+
*/
69+
public function fetchingTheBoardWithId($id) {
70+
$this->sendJSONrequest('GET', '/index.php/apps/deck/boards/' . $id);
71+
}
72+
73+
/**
74+
* @Given /^create a stack named "([^"]*)"$/
75+
*/
76+
public function createAStackNamed($name) {
77+
$this->sendJSONrequest('POST', '/index.php/apps/deck/stacks', [
78+
'title' => $name,
79+
'boardId' => $this->board['id']
80+
]);
81+
$this->response->getBody()->seek(0);
82+
$this->stack = json_decode((string)$this->response->getBody(), true);
83+
}
84+
85+
/**
86+
* @Given /^create a card named "([^"]*)"$/
87+
*/
88+
public function createACardNamed($name) {
89+
$this->sendJSONrequest('POST', '/index.php/apps/deck/cards', [
90+
'title' => $name,
91+
'stackId' => $this->stack['id']
92+
]);
93+
$this->response->getBody()->seek(0);
94+
$this->card = json_decode((string)$this->response->getBody(), true);
95+
}
96+
97+
/**
98+
* @Given /^the current user should have read permissions on the board$/
99+
*/
100+
public function theCurrentUserShouldHaveReadPermissionsOnTheBoard() {
101+
Assert::assertTrue($this->board['permissions']['PERMISSION_READ']);
102+
}
103+
104+
/**
105+
* @Given /^the current user should have write permissions on the board$/
106+
*/
107+
public function theCurrentUserShouldHaveWritePermissionsOnTheBoard() {
108+
Assert::assertTrue($this->board['permissions']['PERMISSION_EDIT']);
109+
}
110+
111+
/**
112+
* @Given /^the current user should have share permissions on the board$/
113+
*/
114+
public function theCurrentUserShouldHaveSharePermissionsOnTheBoard() {
115+
Assert::assertTrue($this->board['permissions']['PERMISSION_SHARE']);
116+
}
117+
118+
/**
119+
* @Given /^the current user should have manage permissions on the board$/
120+
*/
121+
public function theCurrentUserShouldHaveManagePermissionsOnTheBoard() {
122+
Assert::assertTrue($this->board['permissions']['PERMISSION_MANAGE']);
123+
}
124+
125+
}
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
<?php
2+
3+
use Behat\Behat\Context\Context;
4+
use Behat\Gherkin\Node\TableNode;
5+
use GuzzleHttp\Client;
6+
use Behat\Gherkin\Node\PyStringNode;
7+
use GuzzleHttp\Exception\ClientException;
8+
use PHPUnit\Framework\Assert;
9+
10+
require_once __DIR__ . '/../../vendor/autoload.php';
11+
12+
class BoardContext implements Context {
13+
use RequestTrait;
14+
15+
/** @var array Last board response */
16+
private $board = null;
17+
18+
/**
19+
* @Given /^creates a board named "([^"]*)" with color "([^"]*)"$/
20+
*/
21+
public function createsABoardNamedWithColor($title, $color) {
22+
$this->sendJSONrequest('POST', '/index.php/apps/deck/boards', [
23+
'title' => $title,
24+
'color' => $color
25+
]);
26+
$this->response->getBody()->seek(0);
27+
$this->board = json_decode((string)$this->response->getBody(), true);
28+
29+
}
30+
31+
/**
32+
* @When /^fetches the board named "([^"]*)"$/
33+
*/
34+
public function fetchesTheBoardNamed($boardName) {
35+
$this->sendJSONrequest('GET', '/index.php/apps/deck/boards/' . $this->board['id'], []);
36+
$this->response->getBody()->seek(0);
37+
$this->board = json_decode((string)$this->response->getBody(), true);
38+
}
39+
40+
/**
41+
* @When shares the board with user :user
42+
*/
43+
public function sharesTheBoardWithUser($user)
44+
{
45+
$this->sendJSONrequest('POST', '/index.php/apps/deck/boards/' . $this->board['id'] . '/acl', [
46+
'type' => 0,
47+
'participant' => $user,
48+
'permissionEdit' => true,
49+
'permissionShare' => true,
50+
'permissionManage' => true,
51+
]);
52+
}
53+
54+
/**
55+
* @Given /^the current user should have read permissions on the board$/
56+
*/
57+
public function theCurrentUserShouldHaveReadPermissionsOnTheBoard() {
58+
Assert::assertTrue($this->board['permissions']['PERMISSION_READ']);
59+
}
60+
61+
/**
62+
* @Given /^the current user should have write permissions on the board$/
63+
*/
64+
public function theCurrentUserShouldHaveWritePermissionsOnTheBoard() {
65+
Assert::assertTrue($this->board['permissions']['PERMISSION_EDIT']);
66+
}
67+
68+
/**
69+
* @Given /^the current user should have share permissions on the board$/
70+
*/
71+
public function theCurrentUserShouldHaveSharePermissionsOnTheBoard() {
72+
Assert::assertTrue($this->board['permissions']['PERMISSION_SHARE']);
73+
}
74+
75+
/**
76+
* @Given /^the current user should have manage permissions on the board$/
77+
*/
78+
public function theCurrentUserShouldHaveManagePermissionsOnTheBoard() {
79+
Assert::assertTrue($this->board['permissions']['PERMISSION_MANAGE']);
80+
}
81+
82+
/**
83+
* @When /^fetching the board list$/
84+
*/
85+
public function fetchingTheBoardList() {
86+
$this->sendJSONrequest('GET', '/index.php/apps/deck/boards');
87+
}
88+
89+
/**
90+
* @When /^fetching the board with id "([^"]*)"$/
91+
*/
92+
public function fetchingTheBoardWithId($id) {
93+
$this->sendJSONrequest('GET', '/index.php/apps/deck/boards/' . $id);
94+
}
95+
96+
}

0 commit comments

Comments
 (0)