-
Notifications
You must be signed in to change notification settings - Fork 182
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve tests for Attachment::download()
- Loading branch information
Showing
5 changed files
with
108 additions
and
28 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,47 @@ | ||
<?php | ||
|
||
namespace Redmine\Tests\Unit\Api\Attachment; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Redmine\Api\Attachment; | ||
use Redmine\Tests\Fixtures\AssertingHttpClient; | ||
|
||
/** | ||
* @covers \Redmine\Api\Attachment::download | ||
*/ | ||
class DownloadTest extends TestCase | ||
{ | ||
/** | ||
* @dataProvider getDownloadData | ||
*/ | ||
public function testDownloadReturnsCorrectResponse($id, $expectedPath, $response, $expectedReturn) | ||
{ | ||
$client = AssertingHttpClient::create( | ||
$this, | ||
[ | ||
'GET', | ||
$expectedPath, | ||
'', | ||
'', | ||
200, | ||
'application/json', | ||
$response | ||
] | ||
); | ||
|
||
// Create the object under test | ||
$api = new Attachment($client); | ||
|
||
// Perform the tests | ||
$this->assertSame($expectedReturn, $api->download($id)); | ||
} | ||
|
||
public static function getDownloadData(): array | ||
{ | ||
return [ | ||
'string response with integer id' => [5, '/attachments/download/5', 'attachment-content', 'attachment-content'], | ||
'string response with string id' => ['5', '/attachments/download/5', 'attachment-content', 'attachment-content'], | ||
'false response' => [5, '/attachments/download/5', '', false], | ||
]; | ||
} | ||
} |
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