status = 'Active'; $current_user->is_admin = 1; $current_user->save(); $GLOBALS['db']->commit(); // Making sure we commit any changes before continuing } public function tearDown() { parent::tearDown(); SugarTestUserUtilities::removeAllCreatedAnonymousUsers(); unset($GLOBALS['current_user']); } /** * _makeRestCall * * This function helps wrap the REST call using the CURL libraries * * @param $method String name of the method to call * @param $parameters Mixed array of arguments depending on the method call * * @return mixed JSON decoded response made from REST call */ protected function _makeRESTCall($method) { // specify the REST web service to interact with $url = $GLOBALS['sugar_config']['site_url'].'/service/v4/rest.php'; // Open a curl session for making the call $curl = curl_init($url); // set URL and other appropriate options curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_HEADER, 0); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 0); curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0 ); // build the request URL $json = json_encode(array()); $postArgs = "method=$method&input_type=JSON&response_type=JSON&rest_data=$json"; curl_setopt($curl, CURLOPT_POSTFIELDS, $postArgs); // Make the REST call, returning the result $response = curl_exec($curl); // Close the connection $return = curl_getinfo($curl); curl_close($curl); // Convert the result from JSON format to a PHP array return $return; } /** * @group 41523 */ public function testRestReturnContentType() { $results = $this->_makeRESTCall('get_server_info'); $this->assertEquals('application/json; charset=UTF-8', $results['content_type']); } }