Skip to content

Commit b6991d4

Browse files
committed
Tested "getCreateMeta" method
1 parent ed2d93b commit b6991d4

File tree

3 files changed

+156
-2
lines changed

3 files changed

+156
-2
lines changed

src/Jira/Api.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,8 @@ public function getRoleDetails($project_key, $role_id)
331331
* an issue type that does not exist is not an error.
332332
* @param array $expand Optional list of entities to expand in the response.
333333
*
334-
* @return array|false
334+
* @return array
335+
* @link https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-issues/#api-rest-api-2-issue-createmeta-get
335336
*/
336337
public function getCreateMeta(
337338
array $project_ids = null,
@@ -340,7 +341,7 @@ public function getCreateMeta(
340341
array $issue_type_names = null,
341342
array $expand = null
342343
) {
343-
// Create comma separated query parameters for the supplied filters.
344+
// Create comma-separated query parameters for the supplied filters.
344345
$data = array();
345346

346347
if ( $project_ids !== null ) {

tests/Jira/ApiTest.php

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,4 +454,94 @@ public function testGetAttachmentsMetaInformation()
454454
$this->assertApiResponse($response, $this->api->getAttachmentsMetaInformation());
455455
}
456456

457+
/**
458+
* @dataProvider getCreateMetaDataProvider
459+
*/
460+
public function testGetCreateMeta(
461+
array $project_ids = null,
462+
array $project_keys = null,
463+
array $issue_type_ids = null,
464+
array $issue_type_names = null,
465+
array $expand = null,
466+
array $params = array()
467+
) {
468+
$response = file_get_contents(__DIR__ . '/resources/api_get_create_meta.json');
469+
470+
$this->expectClientCall(
471+
Api::REQUEST_GET,
472+
'/rest/api/2/issue/createmeta',
473+
$params,
474+
$response
475+
);
476+
477+
// Perform the API call.
478+
$actual = $this->api->getCreateMeta($project_ids, $project_keys, $issue_type_ids, $issue_type_names, $expand);
479+
$response_decoded = json_decode($response, true);
480+
481+
$this->assertEquals($response_decoded, $actual, 'The decoded response does not match the actual result.');
482+
}
483+
484+
public static function getCreateMetaDataProvider()
485+
{
486+
return array(
487+
'project_ids' => array(
488+
array(123, 456),
489+
null,
490+
null,
491+
null,
492+
null,
493+
array('projectIds' => '123,456'),
494+
),
495+
'project_names' => array(
496+
null,
497+
array('abc', 'def'),
498+
null,
499+
null,
500+
null,
501+
array('projectKeys' => 'abc,def'),
502+
),
503+
'project_ids+project_names' => array(
504+
array(123, 456),
505+
array('abc', 'def'),
506+
null,
507+
null,
508+
null,
509+
array('projectIds' => '123,456', 'projectKeys' => 'abc,def'),
510+
),
511+
512+
'issue_type_ids' => array(
513+
null,
514+
null,
515+
array(123, 456),
516+
null,
517+
null,
518+
array('issuetypeIds' => '123,456'),
519+
),
520+
'issue_type_names' => array(
521+
null,
522+
null,
523+
null,
524+
array('abc', 'def'),
525+
null,
526+
array('issuetypeNames' => 'abc,def'),
527+
),
528+
'issue_type_ids+issue_type_names' => array(
529+
null,
530+
null,
531+
array(123, 456),
532+
array('abc', 'def'),
533+
null,
534+
array('issuetypeIds' => '123,456', 'issuetypeNames' => 'abc,def'),
535+
),
536+
'expand' => array(
537+
null,
538+
null,
539+
null,
540+
null,
541+
array('aa', 'bb'),
542+
array('expand' => 'aa,bb'),
543+
),
544+
);
545+
}
546+
457547
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
{
2+
"expand": "projects",
3+
"projects": [
4+
{
5+
"self": "https://test.atlassian.net/rest/api/2/project/10034",
6+
"id": "10034",
7+
"key": "PRJ1",
8+
"name": "Advanced",
9+
"avatarUrls": {
10+
"48x48": "https://test.atlassian.net/rest/api/2/universal_avatar/view/type/project/avatar/10400",
11+
"24x24": "https://test.atlassian.net/rest/api/2/universal_avatar/view/type/project/avatar/10400?size=small",
12+
"16x16": "https://test.atlassian.net/rest/api/2/universal_avatar/view/type/project/avatar/10400?size=xsmall",
13+
"32x32": "https://test.atlassian.net/rest/api/2/universal_avatar/view/type/project/avatar/10400?size=medium"
14+
},
15+
"issuetypes": [
16+
{
17+
"self": "https://test.atlassian.net/rest/api/2/issuetype/10034",
18+
"id": "10034",
19+
"description": "A problem which impairs or prevents the functions of the product.",
20+
"iconUrl": "https://test.atlassian.net/rest/api/2/universal_avatar/view/type/issuetype/avatar/10303?size=medium",
21+
"name": "Bug Report",
22+
"untranslatedName": "Bug Report",
23+
"subtask": false,
24+
"hierarchyLevel": 0
25+
},
26+
{
27+
"self": "https://test.atlassian.net/rest/api/2/issuetype/10035",
28+
"id": "10035",
29+
"description": "",
30+
"iconUrl": "https://test.atlassian.net/rest/api/2/universal_avatar/view/type/issuetype/avatar/10310?size=medium",
31+
"name": "Refactoring",
32+
"untranslatedName": "Refactoring",
33+
"subtask": false,
34+
"hierarchyLevel": 0
35+
}
36+
]
37+
},
38+
{
39+
"self": "https://test.atlassian.net/rest/api/2/project/10045",
40+
"id": "10045",
41+
"key": "PRJ2",
42+
"name": "Bootstrap",
43+
"avatarUrls": {
44+
"48x48": "https://test.atlassian.net/rest/api/2/universal_avatar/view/type/project/avatar/10418",
45+
"24x24": "https://test.atlassian.net/rest/api/2/universal_avatar/view/type/project/avatar/10418?size=small",
46+
"16x16": "https://test.atlassian.net/rest/api/2/universal_avatar/view/type/project/avatar/10418?size=xsmall",
47+
"32x32": "https://test.atlassian.net/rest/api/2/universal_avatar/view/type/project/avatar/10418?size=medium"
48+
},
49+
"issuetypes": [
50+
{
51+
"self": "https://test.atlassian.net/rest/api/2/issuetype/10034",
52+
"id": "10034",
53+
"description": "A problem which impairs or prevents the functions of the product.",
54+
"iconUrl": "https://test.atlassian.net/rest/api/2/universal_avatar/view/type/issuetype/avatar/10303?size=medium",
55+
"name": "Bug Report",
56+
"untranslatedName": "Bug Report",
57+
"subtask": false,
58+
"hierarchyLevel": 0
59+
}
60+
]
61+
}
62+
]
63+
}

0 commit comments

Comments
 (0)