chobie\Jira\Api::getResolutions PHP Method

getResolutions() public method

Returns a list of all resolutions.
Since: 2.0.0
public getResolutions ( ) : array
return array
    public function getResolutions()
    {
        // Fetch resolutions when the method is called for the first time.
        if ($this->resolutions === null) {
            $resolutions = array();
            $result = $this->api(self::REQUEST_GET, '/rest/api/2/resolution', array(), true);
            foreach ($result as $resolution) {
                $resolutions[$resolution['id']] = $resolution;
            }
            $this->resolutions = $resolutions;
        }
        return $this->resolutions;
    }

Usage Example

Example #1
0
 public function testGetResolutions()
 {
     $response = file_get_contents(__DIR__ . '/resources/api_resolution.json');
     $this->expectClientCall(Api::REQUEST_GET, '/rest/api/2/resolution', array(), $response);
     $actual = $this->api->getResolutions();
     $response_decoded = json_decode($response, true);
     $expected = array('1' => $response_decoded[0], '10000' => $response_decoded[1]);
     $this->assertEquals($expected, $actual);
     // Second time we call the method the results should be cached and not trigger an API Request.
     $this->client->sendRequest(Api::REQUEST_GET, '/rest/api/2/resolution', array(), self::ENDPOINT, $this->credential)->shouldNotBeCalled();
     $this->assertEquals($expected, $this->api->getResolutions(), 'Calling twice did not yield the same results');
 }