-
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.
Add IssueStatus::list() method, deprecate all() method
- Loading branch information
Showing
4 changed files
with
130 additions
and
4 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,79 @@ | ||
<?php | ||
|
||
namespace Redmine\Tests\Unit\Api\IssueStatus; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Redmine\Api\IssueStatus; | ||
use Redmine\Client\Client; | ||
|
||
/** | ||
* Tests for IssueStatus::list() | ||
*/ | ||
class ListTest extends TestCase | ||
{ | ||
/** | ||
* @covers \Redmine\Api\IssueStatus::list | ||
*/ | ||
public function testListWithoutParametersReturnsResponse() | ||
{ | ||
// Test values | ||
$response = '["API Response"]'; | ||
$expectedReturn = ['API Response']; | ||
|
||
// Create the used mock objects | ||
$client = $this->createMock(Client::class); | ||
$client->expects($this->once()) | ||
->method('requestGet') | ||
->with( | ||
$this->stringStartsWith('/issue_statuses.json') | ||
) | ||
->willReturn(true); | ||
$client->expects($this->exactly(1)) | ||
->method('getLastResponseBody') | ||
->willReturn($response); | ||
$client->expects($this->exactly(1)) | ||
->method('getLastResponseContentType') | ||
->willReturn('application/json'); | ||
|
||
// Create the object under test | ||
$api = new IssueStatus($client); | ||
|
||
// Perform the tests | ||
$this->assertSame($expectedReturn, $api->list()); | ||
} | ||
|
||
/** | ||
* @covers \Redmine\Api\IssueStatus::list | ||
*/ | ||
public function testListWithParametersReturnsResponse() | ||
{ | ||
// Test values | ||
$parameters = ['not-used']; | ||
$response = '["API Response"]'; | ||
$expectedReturn = ['API Response']; | ||
|
||
// Create the used mock objects | ||
$client = $this->createMock(Client::class); | ||
$client->expects($this->once()) | ||
->method('requestGet') | ||
->with( | ||
$this->logicalAnd( | ||
$this->stringStartsWith('/issue_statuses.json'), | ||
$this->stringContains('not-used') | ||
) | ||
) | ||
->willReturn(true); | ||
$client->expects($this->exactly(1)) | ||
->method('getLastResponseBody') | ||
->willReturn($response); | ||
$client->expects($this->exactly(1)) | ||
->method('getLastResponseContentType') | ||
->willReturn('application/json'); | ||
|
||
// Create the object under test | ||
$api = new IssueStatus($client); | ||
|
||
// Perform the tests | ||
$this->assertSame($expectedReturn, $api->list($parameters)); | ||
} | ||
} |
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