public function testDownloadCallbackError() { $download_before_send_called = false; $download_callback_called = false; $multi_curl = new MultiCurl(); $multi_curl->beforeSend(function ($instance) use(&$download_before_send_called) { PHPUnit_Framework_Assert::assertFalse($download_before_send_called); $download_before_send_called = true; }); $multi_curl->addDownload(Test::ERROR_URL, function ($instance, $fh) use(&$download_callback_called) { $download_callback_called = true; }); $multi_curl->start(); $this->assertTrue($download_before_send_called); $this->assertFalse($download_callback_called); }
<?php require __DIR__ . '/vendor/autoload.php'; use Curl\MultiCurl; $callback = function ($instance, $tmpfile) { $save_to_path = '/tmp/' . basename($instance->url); $fh = fopen($save_to_path, 'wb'); stream_copy_to_stream($tmpfile, $fh); fclose($fh); }; $multi_curl = new MultiCurl(); $multi_curl->addDownload('https://secure.php.net/images/logos/php-med-trans.png', $callback); $multi_curl->addDownload('https://upload.wikimedia.org/wikipedia/commons/c/c1/PHP_Logo.png', $callback); $multi_curl->start();
<?php require '../src/Curl/Curl.php'; require '../src/Curl/MultiCurl.php'; use Curl\Curl; use Curl\MultiCurl; $multi_curl = new MultiCurl(); $multi_curl->addDownload('https://php.net/images/logos/php-med-trans.png', '/tmp/php-med-trans.png'); $multi_curl->addDownload('https://upload.wikimedia.org/wikipedia/commons/c/c1/PHP_Logo.png', '/tmp/PHP_Logo.png'); $multi_curl->start();
public function testDownloadCallbackError() { $this->markTestSkipped('Callbacks not permitted at this time. SugarCRM disallows the use of call_user_func[_array]'); $this->markTestSkipped('Downloading is disabled as it used file handlers. SugarCRM disallows fopen and fclose.'); $download_before_send_called = false; $download_callback_called = false; $multi_curl = new MultiCurl(); $multi_curl->beforeSend(function ($instance) use(&$download_before_send_called) { PHPUnit_Framework_Assert::assertFalse($download_before_send_called); $download_before_send_called = true; }); $multi_curl->addDownload(Test::ERROR_URL, function ($instance, $fh) use(&$download_callback_called) { $download_callback_called = true; }); $multi_curl->start(); $this->assertTrue($download_before_send_called); $this->assertFalse($download_callback_called); }