diff --git a/README.md b/README.md index 9ceb18ae..70a3314d 100644 --- a/README.md +++ b/README.md @@ -311,7 +311,7 @@ try { $issueService = new IssueService(); // get issue's time tracking info - $ret = $issueService->getWorklog($this->issueKey); + $ret = $issueService->getTimeTracking($this->issueKey); var_dump($ret); $timeTracking = new TimeTracking; @@ -320,7 +320,7 @@ try { $timeTracking->setRemainingEstimate('1w 2d 3h'); // add time tracking - $ret = $issueService->worklog($this->issueKey, $timeTracking); + $ret = $issueService->timeTracking($this->issueKey, $timeTracking); var_dump($ret); } catch (JIRAException $e) { $this->assertTrue(false, 'testSearch Failed : '.$e->getMessage()); diff --git a/src/Issue/IssueField.php b/src/Issue/IssueField.php index d98f5aef..0af39c78 100644 --- a/src/Issue/IssueField.php +++ b/src/Issue/IssueField.php @@ -150,7 +150,7 @@ public function getIssueType() public $progress; /** @var TimeTracking */ - public $timetracking; + public $timeTracking; /** @var IssueType */ public $issuetype; diff --git a/src/Issue/IssueService.php b/src/Issue/IssueService.php index 700ba480..20820219 100644 --- a/src/Issue/IssueService.php +++ b/src/Issue/IssueService.php @@ -223,32 +223,32 @@ public function search($jql, $startAt=0, $maxResults=15, $fields=[]) } /** - * get worklog info + * get TimeTracking info * * @param type $issueIdOrKey * @return type @TimeTracking */ - public function getWorklog($issueIdOrKey) + public function getTimeTracking($issueIdOrKey) { $ret = $this->exec($this->uri . "/$issueIdOrKey", null); - $this->log->addDebug("getWorklog res=$ret\n"); + $this->log->addDebug("getTimeTracking res=$ret\n"); $issue = $this->json_mapper->map( json_decode($ret), new Issue() ); - return $issue->fields->timetracking; + return $issue->fields->timeTracking; } /** - * worklog issues + * TimeTracking issues * * @param issueIdOrKey Issue id or key * @param timeTracking TimeTracking * - * @return TimeTracking + * @return type @TimeTracking */ - public function worklog($issueIdOrKey, $timeTracking) + public function timeTracking($issueIdOrKey, $timeTracking) { $array = ["update" => [ @@ -260,16 +260,12 @@ public function worklog($issueIdOrKey, $timeTracking) $data = json_encode($array); - $this->log->addDebug("worklog req=$data\n"); + $this->log->addDebug("TimeTracking req=$data\n"); + // if success, just return HTTP 201. $ret = $this->exec($this->uri . "/$issueIdOrKey", $data, 'PUT'); - // FIXME - $result = $this->json_mapper->map( - json_decode($ret), new TimeTracking() - ); - - return $result; + return $ret; } } diff --git a/tests/TimeTrackingTest.php b/tests/TimeTrackingTest.php index d0c10e77..ce6b7023 100644 --- a/tests/TimeTrackingTest.php +++ b/tests/TimeTrackingTest.php @@ -7,14 +7,14 @@ class TimeTrackingTest extends PHPUnit_Framework_TestCase { - private $issueKey = 'TEST-961'; + private $issueKey = 'TEST-76'; public function testGetTimeTracking() { try { $issueService = new IssueService(); - $ret = $issueService->getWorklog($this->issueKey); + $ret = $issueService->getTimeTracking($this->issueKey); var_dump($ret); } catch (JIRAException $e) { $this->assertTrue(false, 'testGetTimeTracking Failed : '.$e->getMessage()); @@ -31,7 +31,7 @@ public function testPostTimeTracking() try { $issueService = new IssueService(); - $ret = $issueService->worklog($this->issueKey, $timeTracking); + $ret = $issueService->timeTracking($this->issueKey, $timeTracking); var_dump($ret); } catch (JIRAException $e) { $this->assertTrue(false, 'testPostTimeTracking Failed : '.$e->getMessage());