mirror of
https://github.com/php-curl-class/php-curl-class.git
synced 2026-09-05 07:16:27 +00:00
Add curl extension loaded test
This commit is contained in:
@@ -3,6 +3,10 @@ class Curl {
|
||||
const USER_AGENT = 'PHP-Curl-Class/1.0 (+https://github.com/php-curl-class/php-curl-class)';
|
||||
|
||||
function __construct() {
|
||||
if (!extension_loaded('curl')) {
|
||||
throw new ErrorException('cURL library is not loaded');
|
||||
}
|
||||
|
||||
$this->curl = curl_init();
|
||||
$this->setUserAgent(self::USER_AGENT);
|
||||
$this->setopt(CURLOPT_RETURNTRANSFER, TRUE);
|
||||
|
||||
@@ -24,6 +24,10 @@ class Test {
|
||||
}
|
||||
|
||||
class CurlTest extends PHPUnit_Framework_TestCase {
|
||||
public function testExtensionLoaded() {
|
||||
$this->assertTrue(extension_loaded('curl'));
|
||||
}
|
||||
|
||||
public function testUserAgent() {
|
||||
$test = new Test();
|
||||
$test->curl->setUserAgent(Curl::USER_AGENT);
|
||||
|
||||
Reference in New Issue
Block a user