Skip to content

Commit

Permalink
PR merge advanced search, and write the example codes.
Browse files Browse the repository at this point in the history
  • Loading branch information
lesstif committed Jul 29, 2015
1 parent 9fb3dad commit 409cd2e
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ before_install:
- travis_retry composer self-update

script:
- ./vendor/bin/phpunit --verbose
- ./vendor/bin/phpunit --verbose tests/MockTest

matrix:
allow_failures:
Expand Down
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ copy .env.example file to .env on your project root.
- [Update issue](#update-issue)
- [Add comment](#add-comment)
- [Perform a transition on an issue](#perform-a-transition-on-an-issue)
- [Perform an advanced search, using the JQL](#perform-an-advanced-search)

## Get Project Info

Expand Down Expand Up @@ -273,6 +274,27 @@ try {
?>
````

## Perform an advanced search

````php
<?php
require 'vendor/autoload.php';

use JiraRestApi\Issue\IssueService;

$jql = 'project not in (TEST) and assignee = currentUser() and status in (Resolved, closed)';

try {
$issueService = new IssueService();

$ret = $issueService->search($jql);
var_dump($ret);
} catch (JIRAException $e) {
$this->assertTrue(false, 'testSearch Failed : '.$e->getMessage());
}
?>
````

# License

Apache V2 License
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"php": ">=5.4.0",
"netresearch/jsonmapper": "~0.5",
"monolog/monolog": "~1.12",
"vlucas/phpdotenv" : "~1.0"
"vlucas/phpdotenv" : "~1.0",
"mockery/mockery": "^0.9.4"
},
"require-dev": {
"phpunit/phpunit": "~4.4"
Expand Down
14 changes: 14 additions & 0 deletions tests/IssueTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,4 +155,18 @@ public function testTransition($issueKey)
}
}
//

public function testSearch()
{
$issueKey = 'q';
$jql = 'project not in (TEST) and assignee = currentUser() and status in (Resolved, closed)';
try {
$issueService = new IssueService();

$ret = $issueService->search($jql);
var_dump($ret);
} catch (JIRAException $e) {
$this->assertTrue(false, 'testSearch Failed : '.$e->getMessage());
}
}
}
40 changes: 40 additions & 0 deletions tests/MockTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

use JiraRestApi\Project\ProjectService;

use \Mockery as m;

class Temperature
{
public function __construct($service)
{
$this->_service = $service;
}

public function average()
{
$total = 0;
for ($i=0;$i<3;$i++) {
$total += $this->_service->readTemp();
}
return $total/3;
}
}

class MockTest extends PHPUnit_Framework_TestCase
{
public function tearDown()
{
m::close();
}

public function testGetsAverageTemperatureFromThreeServiceReadings()
{
$service = m::mock('service');
$service->shouldReceive('readTemp')->times(3)->andReturn(10, 12, 14);

$temperature = new Temperature($service);

$this->assertEquals(12, $temperature->average());
}
}

0 comments on commit 409cd2e

Please sign in to comment.