File tree Expand file tree Collapse file tree 3 files changed +78
-0
lines changed
Expand file tree Collapse file tree 3 files changed +78
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace JiraRestApi \Status ;
4+
5+
6+ class Status implements \JsonSerializable
7+ {
8+ /** @var int */
9+ public $ id ;
10+
11+ /** @var string */
12+ public $ name ;
13+
14+ /** @var string */
15+ public $ description ;
16+
17+ public function jsonSerialize ()
18+ {
19+ return array_filter (get_object_vars ($ this ));
20+ }
21+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace JiraRestApi \Status ;
4+
5+
6+ use JiraRestApi \JiraException ;
7+ use JsonMapper_Exception ;
8+
9+ class StatusService extends \JiraRestApi \JiraClient
10+ {
11+ private $ uri = '/status ' ;
12+
13+ /**
14+ * get all statuses
15+ * @throws JiraException
16+ * @throws JsonMapper_Exception
17+ *
18+ * @return Status[] array of Project class
19+ */
20+ public function getAll ()
21+ {
22+ if ($ this ->isRestApiV3 ()) {
23+ throw new JiraException ('V3 is currently not supported ' );
24+ }
25+
26+ else {
27+ $ statusObject = new Status ();
28+ }
29+
30+ $ ret = $ this ->exec ($ this ->uri .'/ ' , null );
31+ $ this ->log ->info ("Result= \n" .$ ret );
32+
33+
34+ return $ this ->json_mapper ->mapArray (
35+ json_decode ($ ret , false ),
36+ new \ArrayObject (),
37+ '\JiraRestApi\Status\status '
38+ );
39+ }
40+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ use JiraRestApi \Status \StatusService ;
4+
5+ class StatusTest extends PHPUnit_Framework_TestCase
6+ {
7+ public function testStatus ()
8+ {
9+ $ statusService = new StatusService ();
10+ $ statuses = $ statusService ->getAll ();
11+ foreach ($ statuses as $ s ) {
12+ $ this ->assertTrue ($ s instanceof JiraRestApi \Status \Status);
13+ $ this ->assertTrue (!empty ($ s ->name ) > 0 );
14+ $ this ->assertTrue (!empty ($ s ->id ));
15+ }
16+ }
17+ }
You can’t perform that action at this time.
0 commit comments