Skip to content

Commit 409cd2e

Browse files
committed
PR merge advanced search, and write the example codes.
1 parent 9fb3dad commit 409cd2e

File tree

5 files changed

+79
-2
lines changed

5 files changed

+79
-2
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ before_install:
1111
- travis_retry composer self-update
1212

1313
script:
14-
- ./vendor/bin/phpunit --verbose
14+
- ./vendor/bin/phpunit --verbose tests/MockTest
1515

1616
matrix:
1717
allow_failures:

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ copy .env.example file to .env on your project root.
5252
- [Update issue](#update-issue)
5353
- [Add comment](#add-comment)
5454
- [Perform a transition on an issue](#perform-a-transition-on-an-issue)
55+
- [Perform an advanced search, using the JQL](#perform-an-advanced-search)
5556

5657
## Get Project Info
5758

@@ -273,6 +274,27 @@ try {
273274
?>
274275
````
275276

277+
## Perform an advanced search
278+
279+
````php
280+
<?php
281+
require 'vendor/autoload.php';
282+
283+
use JiraRestApi\Issue\IssueService;
284+
285+
$jql = 'project not in (TEST) and assignee = currentUser() and status in (Resolved, closed)';
286+
287+
try {
288+
$issueService = new IssueService();
289+
290+
$ret = $issueService->search($jql);
291+
var_dump($ret);
292+
} catch (JIRAException $e) {
293+
$this->assertTrue(false, 'testSearch Failed : '.$e->getMessage());
294+
}
295+
?>
296+
````
297+
276298
# License
277299

278300
Apache V2 License

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"php": ">=5.4.0",
88
"netresearch/jsonmapper": "~0.5",
99
"monolog/monolog": "~1.12",
10-
"vlucas/phpdotenv" : "~1.0"
10+
"vlucas/phpdotenv" : "~1.0",
11+
"mockery/mockery": "^0.9.4"
1112
},
1213
"require-dev": {
1314
"phpunit/phpunit": "~4.4"

tests/IssueTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,4 +155,18 @@ public function testTransition($issueKey)
155155
}
156156
}
157157
//
158+
159+
public function testSearch()
160+
{
161+
$issueKey = 'q';
162+
$jql = 'project not in (TEST) and assignee = currentUser() and status in (Resolved, closed)';
163+
try {
164+
$issueService = new IssueService();
165+
166+
$ret = $issueService->search($jql);
167+
var_dump($ret);
168+
} catch (JIRAException $e) {
169+
$this->assertTrue(false, 'testSearch Failed : '.$e->getMessage());
170+
}
171+
}
158172
}

tests/MockTest.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
3+
use JiraRestApi\Project\ProjectService;
4+
5+
use \Mockery as m;
6+
7+
class Temperature
8+
{
9+
public function __construct($service)
10+
{
11+
$this->_service = $service;
12+
}
13+
14+
public function average()
15+
{
16+
$total = 0;
17+
for ($i=0;$i<3;$i++) {
18+
$total += $this->_service->readTemp();
19+
}
20+
return $total/3;
21+
}
22+
}
23+
24+
class MockTest extends PHPUnit_Framework_TestCase
25+
{
26+
public function tearDown()
27+
{
28+
m::close();
29+
}
30+
31+
public function testGetsAverageTemperatureFromThreeServiceReadings()
32+
{
33+
$service = m::mock('service');
34+
$service->shouldReceive('readTemp')->times(3)->andReturn(10, 12, 14);
35+
36+
$temperature = new Temperature($service);
37+
38+
$this->assertEquals(12, $temperature->average());
39+
}
40+
}

0 commit comments

Comments
 (0)