/**
  * @expectedException         OmiseUndefinedException
  * @expectedExceptionMessage  Strange case, don't know why?
  */
 public function testUndefinedException()
 {
     $mock = array('object' => 'error', 'location' => '', 'code' => 'something_strange', 'message' => 'Strange case, don\'t know why?');
     throw OmiseException::getInstance($mock);
 }
 /**
  * Makes a request and returns a decoded JSON data as an associative array.
  * @param string $url
  * @param string $requestMethod
  * @param array $params
  * @throws OmiseException
  * @return array
  */
 protected function execute($url, $requestMethod, $key, $params = null)
 {
     // If this class is execute by phpunit > get test mode.
     if ($_SERVER['SCRIPT_NAME'] == "./vendor/bin/phpunit") {
         $result = $this->_executeTest($url, $requestMethod, $key, $params);
     } else {
         $result = $this->_executeCurl($url, $requestMethod, $key, $params);
     }
     // Decode the JSON response as an associative array.
     $array = json_decode($result, true);
     // If response is invalid or not a JSON.
     if (count($array) === 0 || !isset($array['object'])) {
         throw new Exception('Unknown error. (Bad Response)');
     }
     // If response is an error object.
     if ($array['object'] === 'error') {
         throw OmiseException::getInstance($array);
     }
     return $array;
 }