-
Notifications
You must be signed in to change notification settings - Fork 183
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'v2.x' into add-user-listlogins
- Loading branch information
Showing
6 changed files
with
296 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
@tracker | ||
Feature: Interacting with the REST API for trackers | ||
In order to interact with REST API for trackers | ||
As a user | ||
I want to make sure the Redmine server replies with the correct response | ||
|
||
Scenario: Listing of zero trackers | ||
Given I have a "NativeCurlClient" client | ||
When I list all trackers | ||
Then the response has the status code "200" | ||
And the response has the content type "application/json" | ||
And the returned data has only the following properties | ||
""" | ||
trackers | ||
""" | ||
And the returned data "trackers" property is an array | ||
And the returned data "trackers" property contains "0" items | ||
|
||
Scenario: Listing of multiple trackers | ||
Given I have a "NativeCurlClient" client | ||
And I have an issue status with the name "New" | ||
And I have a tracker with the name "Feature" and default status id "1" | ||
And I have a tracker with the name "Defect" and default status id "1" | ||
When I list all trackers | ||
Then the response has the status code "200" | ||
And the response has the content type "application/json" | ||
And the returned data has only the following properties | ||
""" | ||
trackers | ||
""" | ||
And the returned data "trackers" property is an array | ||
And the returned data "trackers" property contains "2" items | ||
And the returned data "trackers.0" property is an array | ||
And the returned data "trackers.0" property has only the following properties with Redmine version ">= 5.0.0" | ||
""" | ||
id | ||
name | ||
default_status | ||
description | ||
enabled_standard_fields | ||
""" | ||
But the returned data "trackers.0" property has only the following properties with Redmine version "< 5.0.0" | ||
""" | ||
id | ||
name | ||
default_status | ||
description | ||
""" | ||
And the returned data "trackers.0" property contains the following data | ||
| property | value | | ||
| id | 1 | | ||
| name | Feature | | ||
| description | null | | ||
And the returned data "trackers.0.default_status" property contains the following data | ||
| property | value | | ||
| id | 1 | | ||
| name | New | | ||
And the returned data "trackers.0.enabled_standard_fields" property contains the following data with Redmine version ">= 5.1.0" | ||
| property | value | | ||
| 0 | assigned_to_id | | ||
| 1 | category_id | | ||
| 2 | fixed_version_id | | ||
| 3 | parent_issue_id | | ||
| 4 | start_date | | ||
| 5 | due_date | | ||
| 6 | estimated_hours | | ||
| 7 | done_ratio | | ||
| 8 | description | | ||
| 9 | priority_id | | ||
But the returned data "trackers.0.enabled_standard_fields" property contains the following data with Redmine version ">= 5.0.0" | ||
| property | value | | ||
| 0 | assigned_to_id | | ||
| 1 | category_id | | ||
| 2 | fixed_version_id | | ||
| 3 | parent_issue_id | | ||
| 4 | start_date | | ||
| 5 | due_date | | ||
| 6 | estimated_hours | | ||
| 7 | done_ratio | | ||
| 8 | description | | ||
|
||
Scenario: Listing of multiple tracker names | ||
Given I have a "NativeCurlClient" client | ||
And I have an issue status with the name "New" | ||
And I have a tracker with the name "Feature" and default status id "1" | ||
And I have a tracker with the name "Defect" and default status id "1" | ||
When I list all tracker names | ||
Then the response has the status code "200" | ||
And the response has the content type "application/json" | ||
And the returned data contains "2" items | ||
And the returned data contains the following data | ||
| property | value | | ||
| 1 | Feature | | ||
| 2 | Defect | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Redmine\Tests\Unit\Api\Tracker; | ||
|
||
use PHPUnit\Framework\Attributes\CoversClass; | ||
use PHPUnit\Framework\Attributes\DataProvider; | ||
use PHPUnit\Framework\TestCase; | ||
use Redmine\Api\Tracker; | ||
use Redmine\Tests\Fixtures\AssertingHttpClient; | ||
|
||
#[CoversClass(Tracker::class)] | ||
class ListNamesTest extends TestCase | ||
{ | ||
/** | ||
* @dataProvider getListNamesData | ||
*/ | ||
#[DataProvider('getListNamesData')] | ||
public function testListNamesReturnsCorrectResponse($expectedPath, $responseCode, $response, $expectedResponse) | ||
{ | ||
$client = AssertingHttpClient::create( | ||
$this, | ||
[ | ||
'GET', | ||
$expectedPath, | ||
'application/json', | ||
'', | ||
$responseCode, | ||
'application/json', | ||
$response, | ||
], | ||
); | ||
|
||
// Create the object under test | ||
$api = new Tracker($client); | ||
|
||
// Perform the tests | ||
$this->assertSame($expectedResponse, $api->listNames()); | ||
} | ||
|
||
public static function getListNamesData(): array | ||
{ | ||
return [ | ||
'test without trackers' => [ | ||
'/trackers.json', | ||
201, | ||
<<<JSON | ||
{ | ||
"trackers": [] | ||
} | ||
JSON, | ||
[], | ||
], | ||
'test with multiple trackers' => [ | ||
'/trackers.json', | ||
201, | ||
<<<JSON | ||
{ | ||
"trackers": [ | ||
{"id": 7, "name": "Tracker 3"}, | ||
{"id": 8, "name": "Tracker 2"}, | ||
{"id": 9, "name": "Tracker 1"} | ||
] | ||
} | ||
JSON, | ||
[ | ||
7 => "Tracker 3", | ||
8 => "Tracker 2", | ||
9 => "Tracker 1", | ||
], | ||
], | ||
]; | ||
} | ||
|
||
public function testListNamesCallsHttpClientOnlyOnce() | ||
{ | ||
$client = AssertingHttpClient::create( | ||
$this, | ||
[ | ||
'GET', | ||
'/trackers.json', | ||
'application/json', | ||
'', | ||
200, | ||
'application/json', | ||
<<<JSON | ||
{ | ||
"trackers": [ | ||
{ | ||
"id": 1, | ||
"name": "Tracker 1" | ||
} | ||
] | ||
} | ||
JSON, | ||
], | ||
); | ||
|
||
// Create the object under test | ||
$api = new Tracker($client); | ||
|
||
// Perform the tests | ||
$this->assertSame([1 => 'Tracker 1'], $api->listNames()); | ||
$this->assertSame([1 => 'Tracker 1'], $api->listNames()); | ||
$this->assertSame([1 => 'Tracker 1'], $api->listNames()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters