Skip to content

Commit fab4c42

Browse files
committed
Add behat tests for Role::list()
1 parent a3c0dd7 commit fab4c42

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed

tests/Behat/Bootstrap/RoleContextTrait.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
namespace Redmine\Tests\Behat\Bootstrap;
66

7+
use Redmine\Api\Role;
8+
79
trait RoleContextTrait
810
{
911
/**
@@ -28,4 +30,18 @@ public function iHaveARoleWithTheName($name)
2830
],
2931
);
3032
}
33+
34+
/**
35+
* @When I list all roles
36+
*/
37+
public function iListAllRoles()
38+
{
39+
/** @var Role */
40+
$api = $this->getNativeCurlClient()->getApi('role');
41+
42+
$this->registerClientResponse(
43+
$api->list(),
44+
$api->getLastResponse(),
45+
);
46+
}
3147
}

tests/Behat/features/role.feature

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
@role
2+
Feature: Interacting with the REST API for roles
3+
In order to interact with REST API for roles
4+
As a user
5+
I want to make sure the Redmine server replies with the correct response
6+
7+
Scenario: Listing of zero roles
8+
Given I have a "NativeCurlClient" client
9+
When I list all roles
10+
Then the response has the status code "200"
11+
And the response has the content type "application/json"
12+
And the returned data has only the following properties
13+
"""
14+
roles
15+
"""
16+
And the returned data "roles" property is an array
17+
And the returned data "roles" property contains "0" items
18+
19+
Scenario: Listing of multiple roles
20+
Given I have a "NativeCurlClient" client
21+
And I have a role with the name "Reporter"
22+
And I have a role with the name "Developer"
23+
When I list all roles
24+
Then the response has the status code "200"
25+
And the response has the content type "application/json"
26+
And the returned data has only the following properties
27+
"""
28+
roles
29+
"""
30+
And the returned data "roles" property is an array
31+
And the returned data "roles" property contains "2" items
32+
And the returned data "roles.0" property contains "2" items
33+
And the returned data "roles.0" property contains the following data
34+
| property | value |
35+
| id | 3 |
36+
| name | Reporter |
37+
And the returned data "roles.1" property contains "2" items
38+
And the returned data "roles.1" property contains the following data
39+
| property | value |
40+
| id | 4 |
41+
| name | Developer |

0 commit comments

Comments
 (0)