function save_page_data($queries)
{
    $GLOBALS['save_page_return'] = array();
    $multi_curl = new MultiCurl();
    $multi_curl->success(function ($instance) {
        if ($instance->http_status_code == '204') {
            $response = array('status' => 'success');
        } else {
            $response = array('status' => 'error');
        }
        array_push($GLOBALS['save_page_return'], $response);
    });
    $multi_curl->setHeader('Authorization', 'Bearer ' . get_option('sforce_oauth_token'));
    $multi_curl->setHeader('Content-Type', 'application/json');
    foreach ($queries as $api_endpoint => $fields) {
        $url = get_option('sforce_instance_url') . $api_endpoint;
        $fields_json = json_encode($fields, JSON_FORCE_OBJECT);
        $multi_curl->addPatch($url, $fields_json);
    }
    $multi_curl->start();
    return $GLOBALS['save_page_return'];
}
 public function testSetUrl()
 {
     $data = array('key' => 'value');
     $multi_curl = new MultiCurl();
     $multi_curl->setHeader('X-DEBUG-TEST', 'get');
     $multi_curl->setUrl(Test::TEST_URL);
     $multi_curl->addDelete($data)->complete(function ($instance) {
         PHPUnit_Framework_Assert::assertEquals(Test::TEST_URL, $instance->baseUrl);
         PHPUnit_Framework_Assert::assertEquals('key=value', $instance->response);
     });
     $multi_curl->start();
     $multi_curl = new MultiCurl();
     $multi_curl->setHeader('X-DEBUG-TEST', 'get');
     $multi_curl->setUrl(Test::TEST_URL);
     $multi_curl->addGet($data)->complete(function ($instance) {
         PHPUnit_Framework_Assert::assertEquals(Test::TEST_URL, $instance->baseUrl);
         PHPUnit_Framework_Assert::assertEquals('key=value', $instance->response);
     });
     $multi_curl->start();
     $multi_curl = new MultiCurl();
     $multi_curl->setHeader('X-DEBUG-TEST', 'get');
     $multi_curl->setUrl(Test::TEST_URL);
     $multi_curl->addHead($data)->complete(function ($instance) {
         PHPUnit_Framework_Assert::assertEquals(Test::TEST_URL, $instance->baseUrl);
         PHPUnit_Framework_Assert::assertEquals('HEAD /?key=value HTTP/1.1', $instance->requestHeaders['Request-Line']);
     });
     $multi_curl->start();
     $multi_curl = new MultiCurl();
     $multi_curl->setHeader('X-DEBUG-TEST', 'get');
     $multi_curl->setUrl(Test::TEST_URL);
     $multi_curl->addOptions($data)->complete(function ($instance) {
         PHPUnit_Framework_Assert::assertEquals(Test::TEST_URL, $instance->baseUrl);
         PHPUnit_Framework_Assert::assertEquals('key=value', $instance->response);
     });
     $multi_curl = new MultiCurl();
     $multi_curl->setHeader('X-DEBUG-TEST', 'request_method');
     $multi_curl->setUrl(Test::TEST_URL);
     $multi_curl->addPatch($data)->complete(function ($instance) {
         PHPUnit_Framework_Assert::assertEquals(Test::TEST_URL, $instance->baseUrl);
         PHPUnit_Framework_Assert::assertEquals('PATCH', $instance->response);
     });
     $multi_curl = new MultiCurl();
     $multi_curl->setHeader('X-DEBUG-TEST', 'post');
     $multi_curl->setUrl(Test::TEST_URL);
     $multi_curl->addPost($data)->complete(function ($instance) {
         PHPUnit_Framework_Assert::assertEquals(Test::TEST_URL, $instance->baseUrl);
         PHPUnit_Framework_Assert::assertEquals('key=value', $instance->response);
     });
     $multi_curl = new MultiCurl();
     $multi_curl->setHeader('X-DEBUG-TEST', 'put');
     $multi_curl->setUrl(Test::TEST_URL);
     $multi_curl->addPut($data)->complete(function ($instance) {
         PHPUnit_Framework_Assert::assertEquals(Test::TEST_URL, $instance->baseUrl);
         PHPUnit_Framework_Assert::assertEquals('key=value', $instance->response);
     });
 }
 public function testSetUrl()
 {
     $data = array('key' => 'value');
     $multi_curl = new MultiCurl();
     $multi_curl->setUrl(Test::TEST_URL);
     $multi_curl->addDelete($data)->complete(function ($instance) {
         PHPUnit_Framework_Assert::assertEquals('DELETE /?key=value HTTP/1.1', $instance->requestHeaders['Request-Line']);
         PHPUnit_Framework_Assert::assertEquals(Test::TEST_URL . '?key=value', $instance->effectiveUrl);
     });
     $multi_curl->start();
     $multi_curl = new MultiCurl();
     $multi_curl->setUrl(Test::TEST_URL);
     $multi_curl->addGet($data)->complete(function ($instance) {
         PHPUnit_Framework_Assert::assertEquals('GET /?key=value HTTP/1.1', $instance->requestHeaders['Request-Line']);
         PHPUnit_Framework_Assert::assertEquals(Test::TEST_URL . '?key=value', $instance->effectiveUrl);
     });
     $multi_curl->start();
     $multi_curl = new MultiCurl();
     $multi_curl->setUrl(Test::TEST_URL);
     $multi_curl->addHead($data)->complete(function ($instance) {
         PHPUnit_Framework_Assert::assertEquals('HEAD /?key=value HTTP/1.1', $instance->requestHeaders['Request-Line']);
         PHPUnit_Framework_Assert::assertEquals(Test::TEST_URL . '?key=value', $instance->effectiveUrl);
     });
     $multi_curl->start();
     $multi_curl = new MultiCurl();
     $multi_curl->setUrl(Test::TEST_URL);
     $multi_curl->addOptions($data)->complete(function ($instance) {
         PHPUnit_Framework_Assert::assertEquals('OPTIONS /?key=value HTTP/1.1', $instance->requestHeaders['Request-Line']);
         PHPUnit_Framework_Assert::assertEquals(Test::TEST_URL . '?key=value', $instance->effectiveUrl);
     });
     $multi_curl = new MultiCurl();
     $multi_curl->setUrl(Test::TEST_URL);
     $multi_curl->addPatch($data)->complete(function ($instance) {
         PHPUnit_Framework_Assert::assertEquals('PATCH / HTTP/1.1', $instance->requestHeaders['Request-Line']);
         PHPUnit_Framework_Assert::assertEquals(Test::TEST_URL, $instance->effectiveUrl);
     });
     $multi_curl = new MultiCurl();
     $multi_curl->setUrl(Test::TEST_URL);
     $multi_curl->addPost($data)->complete(function ($instance) {
         PHPUnit_Framework_Assert::assertEquals('POST / HTTP/1.1', $instance->requestHeaders['Request-Line']);
         PHPUnit_Framework_Assert::assertEquals(Test::TEST_URL, $instance->effectiveUrl);
     });
     $multi_curl = new MultiCurl();
     $multi_curl->setUrl(Test::TEST_URL);
     $multi_curl->addPut($data)->complete(function ($instance) {
         PHPUnit_Framework_Assert::assertEquals('PUT / HTTP/1.1', $instance->requestHeaders['Request-Line']);
         PHPUnit_Framework_Assert::assertEquals(Test::TEST_URL, $instance->effectiveUrl);
     });
 }
<?php

require '../src/Curl/Curl.php';
require '../src/Curl/MultiCurl.php';
use Curl\Curl;
use Curl\MultiCurl;
$multi_curl = new MultiCurl();
$multi_curl->addPatch('https://httpbin.org/patch', array('id' => '123', 'body' => 'hello world!'));
$multi_curl->addPatch('https://httpbin.org/patch', array('id' => '456', 'body' => 'hello world!'));
$multi_curl->start();