Skip to content

Commit 7620e52

Browse files
committed
Create behat tests for listing time entry activities
1 parent f9e1ea8 commit 7620e52

File tree

3 files changed

+82
-1
lines changed

3 files changed

+82
-1
lines changed

tests/Behat/Bootstrap/TimeEntryActivityContextTrait.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
namespace Redmine\Tests\Behat\Bootstrap;
66

7+
use Redmine\Api\TimeEntryActivity;
8+
79
trait TimeEntryActivityContextTrait
810
{
911
/**
@@ -18,10 +20,24 @@ public function iHaveATimeEntryActiviyWithName(string $activityName)
1820
[
1921
':name' => $activityName,
2022
':position' => 1,
21-
':is_default' => 1,
23+
':is_default' => 0,
2224
':type' => 'TimeEntryActivity',
2325
':active' => 1,
2426
],
2527
);
2628
}
29+
30+
/**
31+
* @When I list all time entry activities
32+
*/
33+
public function iListAllTimeEntryActivities()
34+
{
35+
/** @var TimeEntryActivity */
36+
$api = $this->getNativeCurlClient()->getApi('time_entry_activity');
37+
38+
$this->registerClientResponse(
39+
$api->list(),
40+
$api->getLastResponse(),
41+
);
42+
}
2743
}

tests/Behat/features/time_entry.feature

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Feature: Interacting with the REST API for time_entries
1212
| property | value |
1313
| project_id | 1 |
1414
| hours | 1 |
15+
| activity_id | 1 |
1516
Then the response has the status code "201"
1617
And the response has the content type "application/xml"
1718
And the returned data is an instance of "SimpleXMLElement"
@@ -77,6 +78,7 @@ Feature: Interacting with the REST API for time_entries
7778
| property | value |
7879
| project_id | 1 |
7980
| hours | 1 |
81+
| activity_id | 1 |
8082
When I update the time entry with id "1" and the following data
8183
| property | value |
8284
| project_id | 1 |
@@ -94,6 +96,7 @@ Feature: Interacting with the REST API for time_entries
9496
| property | value |
9597
| project_id | 1 |
9698
| hours | 1 |
99+
| activity_id | 1 |
97100
When I show the time entry with the id "1"
98101
Then the response has the status code "200"
99102
And the response has the content type "application/json"
@@ -168,6 +171,7 @@ Feature: Interacting with the REST API for time_entries
168171
| property | value |
169172
| project_id | 1 |
170173
| hours | 1 |
174+
| activity_id | 1 |
171175
When I remove the time entry with id "1"
172176
Then the response has the status code "204"
173177
And the response has an empty content type
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
@time_entry_activity
2+
Feature: Interacting with the REST API for time entry activities
3+
In order to interact with REST API for time entry activities
4+
As a user
5+
I want to make sure the Redmine server replies with the correct response
6+
7+
Scenario: Listing of zero time entry activities
8+
Given I have a "NativeCurlClient" client
9+
When I list all time entry activities
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+
time_entry_activities
15+
"""
16+
And the returned data "time_entry_activities" property is an array
17+
And the returned data "time_entry_activities" property contains "0" items
18+
19+
@wip
20+
Scenario: Listing of multiple time entry activities
21+
Given I have a "NativeCurlClient" client
22+
And I have a time entry activiy with name "Development"
23+
And I have a time entry activiy with name "Support"
24+
When I list all time entry activities
25+
Then the response has the status code "200"
26+
And the response has the content type "application/json"
27+
And the returned data has only the following properties
28+
"""
29+
time_entry_activities
30+
"""
31+
And the returned data "time_entry_activities" property is an array
32+
And the returned data "time_entry_activities" property contains "2" items
33+
And the returned data "time_entry_activities.0" property is an array
34+
And the returned data "time_entry_activities.0" property has only the following properties
35+
"""
36+
id
37+
name
38+
is_default
39+
active
40+
"""
41+
And the returned data "time_entry_activities.0" property contains the following data
42+
| property | value |
43+
| id | 1 |
44+
| name | Development |
45+
| is_default | false |
46+
| active | true |
47+
And the returned data "time_entry_activities.1" property is an array
48+
And the returned data "time_entry_activities.1" property has only the following properties
49+
"""
50+
id
51+
name
52+
is_default
53+
active
54+
"""
55+
And the returned data "time_entry_activities.1" property contains the following data
56+
| property | value |
57+
| id | 2 |
58+
| name | Support |
59+
| is_default | false |
60+
| active | true |
61+

0 commit comments

Comments
 (0)