diff --git a/tests/helper.inc.php b/tests/helper.inc.php new file mode 100644 index 0000000..91be6f8 --- /dev/null +++ b/tests/helper.inc.php @@ -0,0 +1,16 @@ +curl = new Curl(); + $this->curl->setOpt(CURLOPT_SSL_VERIFYPEER, FALSE); + $this->curl->setOpt(CURLOPT_SSL_VERIFYHOST, FALSE); + } + + function server($request_method, $data='') { + $request_method = strtolower($request_method); + $this->curl->$request_method(self::TEST_URL, $data); + return $this->curl->response; + } +} diff --git a/tests/run.php b/tests/run.php index 1262ba1..cb8afcd 100644 --- a/tests/run.php +++ b/tests/run.php @@ -2,24 +2,9 @@ // Usage: phpunit --verbose run.php require '../Curl.class.php'; +require 'helper.inc.php'; -class Test { - const TEST_URL = 'https://127.0.0.1/php-curl-class/tests/server.php'; - - function __construct() { - $this->curl = new Curl(); - $this->curl->setOpt(CURLOPT_SSL_VERIFYPEER, FALSE); - $this->curl->setOpt(CURLOPT_SSL_VERIFYHOST, FALSE); - } - - function server($request_method, $data='') { - $request_method = strtolower($request_method); - $this->curl->$request_method(self::TEST_URL, $data); - return $this->curl->response; - } -} - class CurlTest extends PHPUnit_Framework_TestCase { public function testExtensionLoaded() { $this->assertTrue(extension_loaded('curl'));