Skip to content

Commit 86e13e2

Browse files
committed
Merge branch 'v2.x' into add-issuecategory-listnamesbyproject
2 parents d828475 + 31768d5 commit 86e13e2

18 files changed

+233
-72
lines changed

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,15 @@ like [Guzzle](https://github.com/guzzle/guzzle) for handling http connections
2727

2828
## Supported Redmine versions
2929

30-
We support (and run tests against) the [latest Redmine versions](https://www.redmine.org/projects/redmine/wiki/Download#Latest-releases)
31-
that are actively maintained.
30+
We support (and run tests against) the [latest supported Redmine versions](https://www.redmine.org/projects/redmine/wiki/Download#Versions-status-and-releases-policy)
31+
that receive security updates.
3232

3333
- Redmine 5.1.x
3434
- Redmine 5.0.x
35+
- Redmine 4.2.x
3536

3637
Nevertheless, you can also use this library for all older Redmine versions.
37-
In this case, however, be aware that some features may not yet be supported by your Redmine server.
38+
In this case, however, be aware that some features might not be supported by your Redmine server.
3839

3940
If a new Redmine version enables new features that are not yet supported with this library,
4041
you are welcome to [create an issue](https://github.com/kbsali/php-redmine-api/issues).

docker-compose.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,17 @@ services:
5151
volumes:
5252
- ./.docker/redmine-50009_data/files:/usr/src/redmine/files
5353
- ./.docker/redmine-50009_data/sqlite:/usr/src/redmine/sqlite
54+
55+
redmine-40210:
56+
# Redmine 4.2.11 is not available on Docker Hub
57+
# @link https://hub.docker.com/_/redmine/tags?page=&page_size=&ordering=&name=4.2.11
58+
image: redmine:4.2.10
59+
user: "1000:1000"
60+
ports:
61+
- "4210:3000"
62+
environment:
63+
REDMINE_SECRET_KEY_BASE: supersecretkey
64+
REDMINE_PLUGINS_MIGRATE: true
65+
volumes:
66+
- ./.docker/redmine-40210_data/files:/usr/src/redmine/files
67+
- ./.docker/redmine-40210_data/sqlite:/usr/src/redmine/sqlite

tests/Behat/Bootstrap/FeatureContext.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,24 @@ public function theReturnedDataPropertyContainsTheFollowingData($property, Table
290290
$this->assertTableNodeIsSameAsArray($table, $returnData);
291291
}
292292

293+
/**
294+
* @Then the returned data :property property contains the following data with Redmine version :versionComparision
295+
*/
296+
public function theReturnedDataPropertyContainsTheFollowingDataWithRedmineVersion($property, string $versionComparision, TableNode $table)
297+
{
298+
$parts = explode(' ', $versionComparision);
299+
300+
$redmineVersion = RedmineVersion::tryFrom($parts[1]);
301+
302+
if ($redmineVersion === null) {
303+
throw new InvalidArgumentException('Comparison with Redmine ' . $versionComparision . ' is not supported.');
304+
}
305+
306+
if (version_compare($this->redmine->getVersionString(), $parts[1], $parts[0])) {
307+
$this->theReturnedDataPropertyContainsTheFollowingData($property, $table);
308+
}
309+
}
310+
293311
/**
294312
* @Then the returned data :property property has only the following properties
295313
*/

tests/Behat/README.md

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
# Behaviour tests
2+
3+
This folder contains BDD tests using Docker and Behat.
4+
5+
## How to run the tests
6+
7+
Pull the Redmine docker images and start them by running:
8+
9+
```bash
10+
docker compose up -d
11+
```
12+
13+
Now you can run the tests:
14+
15+
```bash
16+
# all tests
17+
docker compose exec php composer behat
18+
# only a specific redmine version
19+
docker compose exec php composer behat -- --suite=redmine_50103
20+
# only specific endpoints
21+
docker compose exec php composer behat -- --tags=issue,group
22+
# only specific endpoints on a specific redmine version
23+
docker compose exec php composer behat -- --suite=redmine_50103 --tags=issue,group
24+
```
25+
26+
## Redmine specific features
27+
28+
Some Redmine features are specific for a Redmine version. There are two ways to handle this situations.
29+
30+
### Modified Rest-API Responses
31+
32+
It is possible that a new Redmine version returns new or changed elements in a response.
33+
This can be handled on the `step` layer:
34+
35+
```
36+
And the returned data "projects.0" property has only the following properties with Redmine version ">= 5.1.0"
37+
"""
38+
id
39+
name
40+
identifier
41+
description
42+
homepage
43+
status
44+
is_public
45+
inherit_members
46+
created_on
47+
updated_on
48+
"""
49+
But the returned data "projects.0" property has only the following properties with Redmine version "< 5.1.0"
50+
"""
51+
id
52+
name
53+
identifier
54+
description
55+
status
56+
is_public
57+
inherit_members
58+
created_on
59+
updated_on
60+
"""
61+
```
62+
63+
### New Rest-API Endpoints
64+
65+
A new Redmine version could be introduce new REST-API endpoints that are missing in the older version.
66+
This can be handled on the `scenario` or `feature` layer.
67+
68+
1. Tag features or scenarios e.g. with `@since50000`.
69+
70+
```
71+
@since50000
72+
Feature: Interacting with the new REST API endpoint
73+
[...]
74+
```
75+
76+
or
77+
78+
```
79+
@since50000
80+
Scenario: Using a new feature
81+
Given I have a "NativeCurlClient" client
82+
And I create a project with name "Test Project" and identifier "test-project"
83+
[...]
84+
```
85+
86+
2. Exclude the tag from the specific suite in the `behat.yml` (note the `~` prefix):
87+
88+
```
89+
default:
90+
suites:
91+
[...]
92+
redmine_40210:
93+
[...]
94+
filters:
95+
tags: "~@since50000"
96+
97+
```
98+
99+
### Removed Rest-API Endpoints
100+
101+
A new Redmine version could remove REST-API endpoints that are missing in the newer versions.
102+
This can be handled on the `scenario` or `feature` layer.
103+
104+
1. Tag features or scenarios e.g. with `@until60000`.
105+
106+
```
107+
@until60000
108+
Feature: Interacting with the a REST API endpoint removed in 6.0.0
109+
[...]
110+
```
111+
112+
or
113+
114+
```
115+
@until60000
116+
Scenario: Using a deprecated feature
117+
Given I have a "NativeCurlClient" client
118+
And I create a project with name "Test Project" and identifier "test-project"
119+
[...]
120+
```
121+
122+
2. Exclude the tag from the specific suite in the `behat.yml` (note the `~` prefix):
123+
124+
```
125+
default:
126+
suites:
127+
[...]
128+
redmine_60000:
129+
[...]
130+
filters:
131+
tags: "~@until60000"
132+
133+
```

tests/Behat/behat.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,11 @@ default:
1212
contexts:
1313
- Redmine\Tests\Behat\Bootstrap\FeatureContext:
1414
redmineVersion: '5.0.9'
15+
redmine_40210:
16+
paths:
17+
- '%paths.base%/features'
18+
contexts:
19+
- Redmine\Tests\Behat\Bootstrap\FeatureContext:
20+
redmineVersion: '4.2.10'
21+
filters:
22+
tags: "~@since50000"

tests/Behat/features/attachments.feature

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1+
@attachment
12
Feature: Interacting with the REST API for attachments
23
In order to interact with REST API for attachments
34
As a user
45
I want to make sure the Redmine server replies with the correct response
56

6-
@attachment
77
Scenario: Uploading an attachment
88
Given I have a "NativeCurlClient" client
99
When I upload the content of the file "%tests_dir%/Fixtures/testfile_01.txt" with the following data
@@ -26,7 +26,7 @@ Feature: Interacting with the REST API for attachments
2626
| id | 1 |
2727
| token | 1.7b962f8af22e26802b87abfa0b07b21dbd03b984ec8d6888dabd3f69cff162f8 |
2828

29-
@attachment
29+
3030
Scenario: Updating the details of an attachment
3131
Given I have a "NativeCurlClient" client
3232
And I create a project with name "Test Project" and identifier "test-project"
@@ -41,7 +41,6 @@ Feature: Interacting with the REST API for attachments
4141
And the response has the content ""
4242
And the returned data is true
4343

44-
@attachment
4544
Scenario: Showing the details of an attachment
4645
Given I have a "NativeCurlClient" client
4746
And I upload the content of the file "%tests_dir%/Fixtures/testfile_01.txt" with the following data
@@ -80,7 +79,7 @@ Feature: Interacting with the REST API for attachments
8079
| id | 1 |
8180
| name | Redmine Admin |
8281

83-
@attachment @error
82+
@error
8483
Scenario: Try to show details of a non-existing attachment
8584
Given I have a "NativeCurlClient" client
8685
When I show the attachment with the id "1"
@@ -89,7 +88,6 @@ Feature: Interacting with the REST API for attachments
8988
And the response has the content ""
9089
And the returned data is false
9190

92-
@attachment
9391
Scenario: Downloading an attachment
9492
Given I have a "NativeCurlClient" client
9593
And I upload the content of the file "%tests_dir%/Fixtures/testfile_01.txt" with the following data
@@ -111,7 +109,7 @@ Feature: Interacting with the REST API for attachments
111109
112110
"""
113111

114-
@attachment @error
112+
@error
115113
Scenario: Try to download a non-existing attachment
116114
Given I have a "NativeCurlClient" client
117115
When I download the attachment with the id "1"
@@ -121,7 +119,6 @@ Feature: Interacting with the REST API for attachments
121119
# And the response has the content "<!DOCTYPE html><html lang="en">..."
122120
And the returned data is false
123121

124-
@attachment
125122
Scenario: Deleting an attachment
126123
Given I have a "NativeCurlClient" client
127124
And I upload the content of the file "%tests_dir%/Fixtures/testfile_01.txt" with the following data

tests/Behat/features/groups.feature

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1+
@group
12
Feature: Interacting with the REST API for groups
23
In order to interact with REST API for groups
34
As a user
45
I want to make sure the Redmine server replies with the correct response
56

6-
@group
77
Scenario: Creating a group with minimal parameters
88
Given I have a "NativeCurlClient" client
99
When I create a group with name "Test Group"
@@ -20,7 +20,6 @@ Feature: Interacting with the REST API for groups
2020
| id | 4 |
2121
| name | Test Group |
2222

23-
@group
2423
Scenario: Listing of zero groups
2524
Given I have a "NativeCurlClient" client
2625
When I list all groups
@@ -33,7 +32,6 @@ Feature: Interacting with the REST API for groups
3332
And the returned data "groups" property is an array
3433
And the returned data "groups" property contains "0" items
3534

36-
@group
3735
Scenario: Listing of one group
3836
Given I have a "NativeCurlClient" client
3937
And I create a group with name "Test Group"
@@ -57,7 +55,6 @@ Feature: Interacting with the REST API for groups
5755
| id | 4 |
5856
| name | Test Group |
5957

60-
@group
6158
Scenario: Listing names of all groups
6259
Given I have a "NativeCurlClient" client
6360
And I create a group with name "Test Group D"
@@ -78,7 +75,6 @@ Feature: Interacting with the REST API for groups
7875
| 7 | Test Group B |
7976
| 8 | Test Group A |
8077

81-
@group
8278
Scenario: Showing a specific group
8379
Given I have a "NativeCurlClient" client
8480
And I create a group with name "Test Group"
@@ -100,7 +96,7 @@ Feature: Interacting with the REST API for groups
10096
| id | 4 |
10197
| name | Test Group |
10298

103-
@group @error
99+
@error
104100
Scenario: Try to show a non-existing group
105101
Given I have a "NativeCurlClient" client
106102
When I show the group with id "40"
@@ -109,7 +105,6 @@ Feature: Interacting with the REST API for groups
109105
And the response has the content ""
110106
And the returned data is false
111107

112-
@group
113108
Scenario: Updating a group
114109
Given I have a "NativeCurlClient" client
115110
And I create a group with the following data
@@ -123,7 +118,6 @@ Feature: Interacting with the REST API for groups
123118
And the response has the content ""
124119
And the returned data is exactly ""
125120

126-
@group
127121
Scenario: Adding an user to a group
128122
Given I have a "NativeCurlClient" client
129123
And I create a group with name "Test Group"
@@ -133,7 +127,6 @@ Feature: Interacting with the REST API for groups
133127
And the response has the content ""
134128
And the returned data is exactly ""
135129

136-
@group
137130
Scenario: Removing an user from a group
138131
Given I have a "NativeCurlClient" client
139132
And I create a group with name "Test Group"
@@ -144,7 +137,6 @@ Feature: Interacting with the REST API for groups
144137
And the response has the content ""
145138
And the returned data is exactly ""
146139

147-
@group
148140
Scenario: Deleting a group
149141
Given I have a "NativeCurlClient" client
150142
And I create a group with name "Test Group"

0 commit comments

Comments
 (0)