Skip to content

Commit a426080

Browse files
committed
Deprecate IssueStatus::listing()
1 parent e30fcf9 commit a426080

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1919
- `Redmine\Api\CustomField::listing()` is deprecated, use `\Redmine\Api\CustomField::listNames()` instead.
2020
- `Redmine\Api\Group::listing()` is deprecated, use `\Redmine\Api\Group::listNames()` instead.
2121
- `Redmine\Api\IssueCategory::listing()` is deprecated, use `\Redmine\Api\IssueCategory::listNamesByProject()` instead.
22+
- `Redmine\Api\IssueStatus::listing()` is deprecated, use `\Redmine\Api\IssueStatus::listNamesByProject()` instead.
2223

2324
## [v2.6.0](https://github.com/kbsali/php-redmine-api/compare/v2.5.0...v2.6.0) - 2024-03-25
2425

src/Redmine/Api/IssueStatus.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,17 @@ public function all(array $params = [])
9999
/**
100100
* Returns an array of issue statuses with name/id pairs.
101101
*
102+
* @deprecated v2.7.0 Use listNames() instead.
103+
* @see IssueStatus::listNames()
104+
*
102105
* @param bool $forceUpdate to force the update of the statuses var
103106
*
104107
* @return array list of issue statuses (id => name)
105108
*/
106109
public function listing($forceUpdate = false)
107110
{
111+
@trigger_error('`' . __METHOD__ . '()` is deprecated since v2.7.0, use `' . __CLASS__ . '::listNames()` instead.', E_USER_DEPRECATED);
112+
108113
if (empty($this->issueStatuses) || $forceUpdate) {
109114
$this->issueStatuses = $this->list();
110115
}

tests/Unit/Api/IssueStatusTest.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,38 @@ public function testListingCallsGetEveryTimeWithForceUpdate()
215215
$this->assertSame($expectedReturn, $api->listing(true));
216216
}
217217

218+
/**
219+
* Test listing().
220+
*/
221+
public function testListingTriggersDeprecationWarning()
222+
{
223+
$client = $this->createMock(Client::class);
224+
$client->method('requestGet')
225+
->willReturn(true);
226+
$client->method('getLastResponseBody')
227+
->willReturn('{"issue_statuses":[{"id":1,"name":"IssueStatus 1"},{"id":5,"name":"IssueStatus 5"}]}');
228+
$client->method('getLastResponseContentType')
229+
->willReturn('application/json');
230+
231+
$api = new IssueStatus($client);
232+
233+
// PHPUnit 10 compatible way to test trigger_error().
234+
set_error_handler(
235+
function ($errno, $errstr): bool {
236+
$this->assertSame(
237+
'`Redmine\Api\IssueStatus::listing()` is deprecated since v2.7.0, use `Redmine\Api\IssueStatus::listNames()` instead.',
238+
$errstr,
239+
);
240+
241+
restore_error_handler();
242+
return true;
243+
},
244+
E_USER_DEPRECATED,
245+
);
246+
247+
$api->listing();
248+
}
249+
218250
/**
219251
* Test getIdByName().
220252
*/

0 commit comments

Comments
 (0)