Skip to content

Commit 20820d1

Browse files
committed
add behat tests for Version::listByProject()
1 parent e502824 commit 20820d1

File tree

2 files changed

+99
-24
lines changed

2 files changed

+99
-24
lines changed

tests/Behat/Bootstrap/VersionContextTrait.php

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,35 +45,49 @@ public function iCreateAVersionWithProjectIdentifierAndWithTheFollowingData(stri
4545
}
4646

4747
/**
48-
* @When I update the version with id :id and the following data
48+
* @When I show the version with id :versionId
4949
*/
50-
public function iUpdateTheVersionWithIdAndTheFollowingData($id, TableNode $table)
50+
public function iShowTheVersionWithId(int $versionId)
5151
{
52-
$data = [];
52+
/** @var Version */
53+
$api = $this->getNativeCurlClient()->getApi('version');
5354

54-
foreach ($table as $row) {
55-
$data[$row['property']] = $row['value'];
56-
}
55+
$this->registerClientResponse(
56+
$api->show($versionId),
57+
$api->getLastResponse(),
58+
);
59+
}
5760

61+
/**
62+
* @When I list all versions for project identifier :identifier
63+
*/
64+
public function iListAllVersionsForProjectIdentifier($identifier)
65+
{
5866
/** @var Version */
5967
$api = $this->getNativeCurlClient()->getApi('version');
6068

6169
$this->registerClientResponse(
62-
$api->update($id, $data),
70+
$api->listByProject($identifier),
6371
$api->getLastResponse(),
6472
);
6573
}
6674

6775
/**
68-
* @When I show the version with id :versionId
76+
* @When I update the version with id :id and the following data
6977
*/
70-
public function iShowTheVersionWithId(int $versionId)
78+
public function iUpdateTheVersionWithIdAndTheFollowingData($id, TableNode $table)
7179
{
80+
$data = [];
81+
82+
foreach ($table as $row) {
83+
$data[$row['property']] = $row['value'];
84+
}
85+
7286
/** @var Version */
7387
$api = $this->getNativeCurlClient()->getApi('version');
7488

7589
$this->registerClientResponse(
76-
$api->show($versionId),
90+
$api->update($id, $data),
7791
$api->getLastResponse(),
7892
);
7993
}

tests/Behat/features/version.feature

Lines changed: 75 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -52,20 +52,6 @@ Feature: Interacting with the REST API for versions
5252
| id | 1 |
5353
| name | Test Project |
5454

55-
Scenario: Updating a version
56-
Given I have a "NativeCurlClient" client
57-
And I create a project with name "Test Project" and identifier "test-project"
58-
And I create a version with project identifier "test-project" with the following data
59-
| property | value |
60-
| name | Test-Version |
61-
When I update the version with id "1" and the following data
62-
| property | value |
63-
| name | New Version name |
64-
Then the response has the status code "204"
65-
And the response has an empty content type
66-
And the response has the content ""
67-
And the returned data is exactly ""
68-
6955
Scenario: Showing a version
7056
Given I have a "NativeCurlClient" client
7157
And I create a project with name "Test Project" and identifier "test-project"
@@ -115,6 +101,81 @@ Feature: Interacting with the REST API for versions
115101
And the response has the content ""
116102
And the returned data is false
117103

104+
Scenario: Listing of zero versions
105+
Given I have a "NativeCurlClient" client
106+
And I create a project with name "Test Project" and identifier "test-project"
107+
When I list all versions for project identifier "test-project"
108+
Then the response has the status code "200"
109+
And the response has the content type "application/json"
110+
And the returned data has only the following properties
111+
"""
112+
versions
113+
total_count
114+
"""
115+
And the returned data contains the following data
116+
| property | value |
117+
| versions | [] |
118+
| total_count | 0 |
119+
120+
Scenario: Listing of multiple versions
121+
Given I have a "NativeCurlClient" client
122+
And I create a project with name "Test Project" and identifier "test-project"
123+
And I create a version with name "Test-Version B" and project identifier "test-project"
124+
And I create a version with name "Test-Version A" and project identifier "test-project"
125+
When I list all versions for project identifier "test-project"
126+
Then the response has the status code "200"
127+
And the response has the content type "application/json"
128+
And the returned data has only the following properties
129+
"""
130+
versions
131+
total_count
132+
"""
133+
And the returned data contains the following data
134+
| property | value |
135+
| total_count | 2 |
136+
And the returned data "versions" property is an array
137+
And the returned data "versions" property contains "2" items
138+
And the returned data "versions.0" property is an array
139+
And the returned data "versions.0" property has only the following properties
140+
"""
141+
id
142+
project
143+
name
144+
description
145+
status
146+
due_date
147+
sharing
148+
wiki_page_title
149+
created_on
150+
updated_on
151+
"""
152+
And the returned data "versions.0" property contains the following data
153+
| property | value |
154+
| id | 1 |
155+
| name | Test-Version B |
156+
| description | |
157+
| status | open |
158+
| sharing | none |
159+
| wiki_page_title | null |
160+
And the returned data "versions.0.project" property contains the following data
161+
| property | value |
162+
| id | 1 |
163+
| name | Test Project |
164+
165+
Scenario: Updating a version
166+
Given I have a "NativeCurlClient" client
167+
And I create a project with name "Test Project" and identifier "test-project"
168+
And I create a version with project identifier "test-project" with the following data
169+
| property | value |
170+
| name | Test-Version |
171+
When I update the version with id "1" and the following data
172+
| property | value |
173+
| name | New Version name |
174+
Then the response has the status code "204"
175+
And the response has an empty content type
176+
And the response has the content ""
177+
And the returned data is exactly ""
178+
118179
Scenario: Removing a version
119180
Given I have a "NativeCurlClient" client
120181
And I create a project with name "Test Project" and identifier "test-project"

0 commit comments

Comments
 (0)