-
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 pull request #408 from Art4/add-customfield-listnames
Add `CustomField::listNames()` method as replacement for `CustomField::listing()`
- Loading branch information
Showing
9 changed files
with
450 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Redmine\Tests\Behat\Bootstrap; | ||
|
||
use Redmine\Api\CustomField; | ||
|
||
trait CustomFieldContextTrait | ||
{ | ||
/** | ||
* @Given I create a custom field for issues with the name :customFieldName | ||
*/ | ||
public function iCreateACustomFieldForIssuesWithTheName($customFieldName) | ||
{ | ||
// support for creating custom fields via REST API is missing | ||
$this->redmine->excecuteDatabaseQuery( | ||
'INSERT INTO custom_fields(type, name, field_format, is_required, is_for_all, position) VALUES(:type, :name, :field_format, :is_required, :is_for_all, :position);', | ||
[], | ||
[ | ||
':type' => 'IssueCustomField', | ||
':name' => $customFieldName, | ||
':field_format' => 'string', | ||
':is_required' => 0, | ||
':is_for_all' => 1, | ||
':position' => 1, | ||
], | ||
); | ||
} | ||
|
||
/** | ||
* @Given I enable the tracker with ID :trackerId for custom field with ID :customFieldId | ||
*/ | ||
public function iEnableTheTrackerWithIdForCustomFieldWithId($trackerId, $customFieldId) | ||
{ | ||
// support for enabling custom fields for trackers via REST API is missing | ||
$this->redmine->excecuteDatabaseQuery( | ||
'INSERT INTO custom_fields_trackers(custom_field_id, tracker_id) VALUES(:custom_field_id, :tracker_id);', | ||
[], | ||
[ | ||
':custom_field_id' => $customFieldId, | ||
':tracker_id' => $trackerId, | ||
], | ||
); | ||
} | ||
|
||
/** | ||
* @When I list all custom fields | ||
*/ | ||
public function iListAllCustomFields() | ||
{ | ||
/** @var CustomField */ | ||
$api = $this->getNativeCurlClient()->getApi('custom_fields'); | ||
|
||
$this->registerClientResponse( | ||
$api->list(), | ||
$api->getLastResponse(), | ||
); | ||
} | ||
|
||
/** | ||
* @When I list all custom field names | ||
*/ | ||
public function iListAllCustomFieldNames() | ||
{ | ||
/** @var CustomField */ | ||
$api = $this->getNativeCurlClient()->getApi('custom_fields'); | ||
|
||
$this->registerClientResponse( | ||
$api->listNames(), | ||
$api->getLastResponse(), | ||
); | ||
} | ||
} |
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,117 @@ | ||
@custom_field | ||
Feature: Interacting with the REST API for custom fields | ||
In order to interact with REST API for custom fields | ||
As a user | ||
I want to make sure the Redmine server replies with the correct response | ||
|
||
Scenario: Listing of zero custom fields | ||
Given I have a "NativeCurlClient" client | ||
When I list all custom fields | ||
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 | ||
""" | ||
custom_fields | ||
""" | ||
And the returned data "custom_fields" property is an array | ||
And the returned data "custom_fields" property contains "0" items | ||
|
||
Scenario: Listing of multiple custom fields | ||
Given I have a "NativeCurlClient" client | ||
And I create a custom field for issues with the name "Note B" | ||
And I create a custom field for issues with the name "Note A" | ||
When I list all custom fields | ||
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 | ||
""" | ||
custom_fields | ||
""" | ||
And the returned data "custom_fields" property is an array | ||
And the returned data "custom_fields" property contains "2" items | ||
# field 'description' was added in Redmine 5.1.0, see https://www.redmine.org/issues/37617 | ||
And the returned data "custom_fields.0" property contains the following data with Redmine version ">= 5.1.0" | ||
| property | value | | ||
| id | 1 | | ||
| name | Note B | | ||
| description | null | | ||
| customized_type | issue | | ||
| field_format | string | | ||
| regexp | | | ||
| min_length | null | | ||
| max_length | null | | ||
| is_required | false | | ||
| is_filter | false | | ||
| searchable | false | | ||
| multiple | false | | ||
| default_value | null | | ||
| visible | true | | ||
| trackers | [] | | ||
| roles | [] | | ||
But the returned data "custom_fields.0" property contains the following data with Redmine version "< 5.1.0" | ||
| property | value | | ||
| id | 1 | | ||
| name | Note B | | ||
| customized_type | issue | | ||
| field_format | string | | ||
| regexp | | | ||
| min_length | null | | ||
| max_length | null | | ||
| is_required | false | | ||
| is_filter | false | | ||
| searchable | false | | ||
| multiple | false | | ||
| default_value | null | | ||
| visible | true | | ||
| trackers | [] | | ||
| roles | [] | | ||
# field 'description' was added in Redmine 5.1.0, see https://www.redmine.org/issues/37617 | ||
And the returned data "custom_fields.1" property contains the following data with Redmine version ">= 5.1.0" | ||
| property | value | | ||
| id | 2 | | ||
| name | Note A | | ||
| description | null | | ||
| customized_type | issue | | ||
| field_format | string | | ||
| regexp | | | ||
| min_length | null | | ||
| max_length | null | | ||
| is_required | false | | ||
| is_filter | false | | ||
| searchable | false | | ||
| multiple | false | | ||
| default_value | null | | ||
| visible | true | | ||
| trackers | [] | | ||
| roles | [] | | ||
But the returned data "custom_fields.1" property contains the following data with Redmine version "< 5.1.0" | ||
| property | value | | ||
| id | 2 | | ||
| name | Note A | | ||
| customized_type | issue | | ||
| field_format | string | | ||
| regexp | | | ||
| min_length | null | | ||
| max_length | null | | ||
| is_required | false | | ||
| is_filter | false | | ||
| searchable | false | | ||
| multiple | false | | ||
| default_value | null | | ||
| visible | true | | ||
| trackers | [] | | ||
| roles | [] | | ||
|
||
Scenario: Listing of multiple custom field names | ||
Given I have a "NativeCurlClient" client | ||
And I create a custom field for issues with the name "Note B" | ||
And I create a custom field for issues with the name "Note A" | ||
When I list all custom field names | ||
Then the response has the status code "200" | ||
And the response has the content type "application/json" | ||
And the returned data is an array | ||
And the returned data contains "2" items | ||
And the returned data contains the following data | ||
| property | value | | ||
| 1 | Note B | | ||
| 2 | Note A | |
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
Oops, something went wrong.