Skip to content

Instantly share code, notes, and snippets.

@lesstif
Created April 29, 2020 08:52
Show Gist options
  • Save lesstif/4bbe3e40089dbc06e923812051ecada5 to your computer and use it in GitHub Desktop.
Save lesstif/4bbe3e40089dbc06e923812051ecada5 to your computer and use it in GitHub Desktop.
get all jira issue's attachments
<?php
use JiraRestApi\Attachment\AttachmentService;
use JiraRestApi\JiraException;
class GetAllJiraAttachmentTest extends PHPUnit_Framework_TestCase
{
public function testGetIssue()
{
$key = 'TEST-484';
try {
$iss = new \JiraRestApi\Issue\IssueService();
$issue = $iss->get($key);
// print all attachments
dump($issue->fields->attachment);
return $issue->fields->attachment;
} catch (JiraException $e) {
$this->assertTrue(false, 'Create Failed : '.$e->getMessage());
}
}
/**
* @depends testGetIssue
*
* @param string $key
* @return int
* @throws JsonMapper_Exception
*/
public function testGetAttachment(array $attachments)
{
try {
foreach ($attachments as $attachment) {
$atts = new AttachmentService();
$att = $atts->get($attachment->id, "output", true);
dump($att);
}
} catch (JiraException $e) {
$this->assertTrue(false, 'Create Failed : '.$e->getMessage());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment