mirror of
https://github.com/php-curl-class/php-curl-class.git
synced 2026-10-25 13:28:08 +00:00
Fix PHPUnit 6.0 release causing build to break.
Use PHPUnit's new namespacing. Add shim for backwards compatibility and run on PHP < 7.0.
This commit is contained in:
@@ -40,7 +40,7 @@ class Test
|
||||
} else {
|
||||
$this->server('request_method', $request_method);
|
||||
}
|
||||
\PHPUnit_Framework_Assert::assertEquals($request_method, $this->curl->responseHeaders['X-REQUEST-METHOD']);
|
||||
\PHPUnit\Framework\Assert::assertEquals($request_method, $this->curl->responseHeaders['X-REQUEST-METHOD']);
|
||||
}
|
||||
|
||||
public function chain_requests($first, $second)
|
||||
|
||||
@@ -4,7 +4,7 @@ use \Curl\Curl;
|
||||
use \Curl\CaseInsensitiveArray;
|
||||
use \Helper\Test;
|
||||
|
||||
class CurlTest extends PHPUnit_Framework_TestCase
|
||||
class CurlTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function testExtensionsLoaded()
|
||||
{
|
||||
@@ -653,13 +653,13 @@ class CurlTest extends PHPUnit_Framework_TestCase
|
||||
$curl->download(Test::TEST_URL . '?' . http_build_query(array(
|
||||
'file_path' => $uploaded_file_path,
|
||||
)), function ($instance, $fh) use (&$callback_called) {
|
||||
PHPUnit_Framework_Assert::assertFalse($callback_called);
|
||||
PHPUnit_Framework_Assert::assertInstanceOf('Curl\Curl', $instance);
|
||||
PHPUnit_Framework_Assert::assertTrue(is_resource($fh));
|
||||
PHPUnit_Framework_Assert::assertEquals('stream', get_resource_type($fh));
|
||||
PHPUnit_Framework_Assert::assertGreaterThan(0, strlen(stream_get_contents($fh)));
|
||||
PHPUnit_Framework_Assert::assertEquals(0, strlen(stream_get_contents($fh)));
|
||||
PHPUnit_Framework_Assert::assertTrue(fclose($fh));
|
||||
\PHPUnit\Framework\Assert::assertFalse($callback_called);
|
||||
\PHPUnit\Framework\Assert::assertInstanceOf('Curl\Curl', $instance);
|
||||
\PHPUnit\Framework\Assert::assertTrue(is_resource($fh));
|
||||
\PHPUnit\Framework\Assert::assertEquals('stream', get_resource_type($fh));
|
||||
\PHPUnit\Framework\Assert::assertGreaterThan(0, strlen(stream_get_contents($fh)));
|
||||
\PHPUnit\Framework\Assert::assertEquals(0, strlen(stream_get_contents($fh)));
|
||||
\PHPUnit\Framework\Assert::assertTrue(fclose($fh));
|
||||
$callback_called = true;
|
||||
});
|
||||
$this->assertTrue($callback_called);
|
||||
@@ -2671,11 +2671,11 @@ class CurlTest extends PHPUnit_Framework_TestCase
|
||||
&$error_called,
|
||||
&$complete_called
|
||||
) {
|
||||
PHPUnit_Framework_Assert::assertInstanceOf('Curl\Curl', $instance);
|
||||
PHPUnit_Framework_Assert::assertFalse($before_send_called);
|
||||
PHPUnit_Framework_Assert::assertFalse($success_called);
|
||||
PHPUnit_Framework_Assert::assertFalse($error_called);
|
||||
PHPUnit_Framework_Assert::assertFalse($complete_called);
|
||||
\PHPUnit\Framework\Assert::assertInstanceOf('Curl\Curl', $instance);
|
||||
\PHPUnit\Framework\Assert::assertFalse($before_send_called);
|
||||
\PHPUnit\Framework\Assert::assertFalse($success_called);
|
||||
\PHPUnit\Framework\Assert::assertFalse($error_called);
|
||||
\PHPUnit\Framework\Assert::assertFalse($complete_called);
|
||||
$before_send_called = true;
|
||||
});
|
||||
$curl->success(function ($instance) use (
|
||||
@@ -2684,11 +2684,11 @@ class CurlTest extends PHPUnit_Framework_TestCase
|
||||
&$error_called,
|
||||
&$complete_called
|
||||
) {
|
||||
PHPUnit_Framework_Assert::assertInstanceOf('Curl\Curl', $instance);
|
||||
PHPUnit_Framework_Assert::assertTrue($before_send_called);
|
||||
PHPUnit_Framework_Assert::assertFalse($success_called);
|
||||
PHPUnit_Framework_Assert::assertFalse($error_called);
|
||||
PHPUnit_Framework_Assert::assertFalse($complete_called);
|
||||
\PHPUnit\Framework\Assert::assertInstanceOf('Curl\Curl', $instance);
|
||||
\PHPUnit\Framework\Assert::assertTrue($before_send_called);
|
||||
\PHPUnit\Framework\Assert::assertFalse($success_called);
|
||||
\PHPUnit\Framework\Assert::assertFalse($error_called);
|
||||
\PHPUnit\Framework\Assert::assertFalse($complete_called);
|
||||
$success_called = true;
|
||||
});
|
||||
$curl->error(function ($instance) use (
|
||||
@@ -2705,11 +2705,11 @@ class CurlTest extends PHPUnit_Framework_TestCase
|
||||
&$error_called,
|
||||
&$complete_called
|
||||
) {
|
||||
PHPUnit_Framework_Assert::assertInstanceOf('Curl\Curl', $instance);
|
||||
PHPUnit_Framework_Assert::assertTrue($before_send_called);
|
||||
PHPUnit_Framework_Assert::assertTrue($success_called);
|
||||
PHPUnit_Framework_Assert::assertFalse($error_called);
|
||||
PHPUnit_Framework_Assert::assertFalse($complete_called);
|
||||
\PHPUnit\Framework\Assert::assertInstanceOf('Curl\Curl', $instance);
|
||||
\PHPUnit\Framework\Assert::assertTrue($before_send_called);
|
||||
\PHPUnit\Framework\Assert::assertTrue($success_called);
|
||||
\PHPUnit\Framework\Assert::assertFalse($error_called);
|
||||
\PHPUnit\Framework\Assert::assertFalse($complete_called);
|
||||
$complete_called = true;
|
||||
});
|
||||
|
||||
@@ -2738,11 +2738,11 @@ class CurlTest extends PHPUnit_Framework_TestCase
|
||||
&$error_called,
|
||||
&$complete_called
|
||||
) {
|
||||
PHPUnit_Framework_Assert::assertInstanceOf('Curl\Curl', $instance);
|
||||
PHPUnit_Framework_Assert::assertFalse($before_send_called);
|
||||
PHPUnit_Framework_Assert::assertFalse($success_called);
|
||||
PHPUnit_Framework_Assert::assertFalse($error_called);
|
||||
PHPUnit_Framework_Assert::assertFalse($complete_called);
|
||||
\PHPUnit\Framework\Assert::assertInstanceOf('Curl\Curl', $instance);
|
||||
\PHPUnit\Framework\Assert::assertFalse($before_send_called);
|
||||
\PHPUnit\Framework\Assert::assertFalse($success_called);
|
||||
\PHPUnit\Framework\Assert::assertFalse($error_called);
|
||||
\PHPUnit\Framework\Assert::assertFalse($complete_called);
|
||||
$before_send_called = true;
|
||||
});
|
||||
$curl->success(function ($instance) use (
|
||||
@@ -2759,11 +2759,11 @@ class CurlTest extends PHPUnit_Framework_TestCase
|
||||
&$error_called,
|
||||
&$complete_called
|
||||
) {
|
||||
PHPUnit_Framework_Assert::assertInstanceOf('Curl\Curl', $instance);
|
||||
PHPUnit_Framework_Assert::assertTrue($before_send_called);
|
||||
PHPUnit_Framework_Assert::assertFalse($success_called);
|
||||
PHPUnit_Framework_Assert::assertFalse($error_called);
|
||||
PHPUnit_Framework_Assert::assertFalse($complete_called);
|
||||
\PHPUnit\Framework\Assert::assertInstanceOf('Curl\Curl', $instance);
|
||||
\PHPUnit\Framework\Assert::assertTrue($before_send_called);
|
||||
\PHPUnit\Framework\Assert::assertFalse($success_called);
|
||||
\PHPUnit\Framework\Assert::assertFalse($error_called);
|
||||
\PHPUnit\Framework\Assert::assertFalse($complete_called);
|
||||
$error_called = true;
|
||||
});
|
||||
$curl->complete(function ($instance) use (
|
||||
@@ -2772,11 +2772,11 @@ class CurlTest extends PHPUnit_Framework_TestCase
|
||||
&$error_called,
|
||||
&$complete_called
|
||||
) {
|
||||
PHPUnit_Framework_Assert::assertInstanceOf('Curl\Curl', $instance);
|
||||
PHPUnit_Framework_Assert::assertTrue($before_send_called);
|
||||
PHPUnit_Framework_Assert::assertFalse($success_called);
|
||||
PHPUnit_Framework_Assert::assertTrue($error_called);
|
||||
PHPUnit_Framework_Assert::assertFalse($complete_called);
|
||||
\PHPUnit\Framework\Assert::assertInstanceOf('Curl\Curl', $instance);
|
||||
\PHPUnit\Framework\Assert::assertTrue($before_send_called);
|
||||
\PHPUnit\Framework\Assert::assertFalse($success_called);
|
||||
\PHPUnit\Framework\Assert::assertTrue($error_called);
|
||||
\PHPUnit\Framework\Assert::assertFalse($complete_called);
|
||||
$complete_called = true;
|
||||
});
|
||||
|
||||
@@ -2800,7 +2800,7 @@ class CurlTest extends PHPUnit_Framework_TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException PHPUnit_Framework_Error_Warning
|
||||
* @expectedException \PHPUnit\Framework\Error\Warning
|
||||
*/
|
||||
public function testRequiredOptionCurlOptReturnTransferEmitsWarning()
|
||||
{
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,3 +1,29 @@
|
||||
phpunit_shim() {
|
||||
# -class CurlTest extends \PHPUnit\Framework\TestCase
|
||||
# +class CurlTest extends PHPUnit_Framework_TestCase
|
||||
find='class CurlTest extends \\PHPUnit\\Framework\\TestCase'
|
||||
replace='class CurlTest extends PHPUnit_Framework_TestCase'
|
||||
sed -i'' -e"s/${find}/${replace}/" "$(pwd)/tests/PHPCurlClass/PHP"*
|
||||
|
||||
# -\PHPUnit\Framework\Assert
|
||||
# +PHPUnit_Framework_Assert
|
||||
find='\\PHPUnit\\Framework\\Assert'
|
||||
replace='PHPUnit_Framework_Assert'
|
||||
sed -i'' -e"s/${find}/${replace}/" "$(pwd)/tests/PHPCurlClass/PHP"*
|
||||
|
||||
# -\PHPUnit\Framework\Assert
|
||||
# +\PHPUnit_Framework_Assert
|
||||
find='\\PHPUnit\\Framework\\Assert'
|
||||
replace='\\PHPUnit_Framework_Assert'
|
||||
sed -i'' -e"s/${find}/${replace}/" "$(pwd)/tests/PHPCurlClass/Helper.php"
|
||||
|
||||
# -\PHPUnit\Framework\Error\Warning
|
||||
# +PHPUnit_Framework_Error_Warning
|
||||
find='\\PHPUnit\\Framework\\Error\\Warning'
|
||||
replace='PHPUnit_Framework_Error_Warning'
|
||||
sed -i'' -e"s/${find}/${replace}/" "$(pwd)/tests/PHPCurlClass/PHP"*
|
||||
}
|
||||
|
||||
set -x
|
||||
echo "TRAVIS_PHP_VERSION: ${TRAVIS_PHP_VERSION}"
|
||||
php -r "var_dump(phpversion());"
|
||||
@@ -31,12 +57,16 @@ server {
|
||||
}
|
||||
EOF
|
||||
sudo /etc/init.d/nginx restart
|
||||
phpunit_shim
|
||||
elif [[ "${TRAVIS_PHP_VERSION}" == "5.4" ]]; then
|
||||
php -S 127.0.0.1:8000 -t tests/PHPCurlClass/ &
|
||||
phpunit_shim
|
||||
elif [[ "${TRAVIS_PHP_VERSION}" == "5.5" ]]; then
|
||||
php -S 127.0.0.1:8000 -t tests/PHPCurlClass/ &
|
||||
phpunit_shim
|
||||
elif [[ "${TRAVIS_PHP_VERSION}" == "5.6" ]]; then
|
||||
php -S 127.0.0.1:8000 -t tests/PHPCurlClass/ &
|
||||
phpunit_shim
|
||||
elif [[ "${TRAVIS_PHP_VERSION}" == "7.0" ]]; then
|
||||
php -S 127.0.0.1:8000 -t tests/PHPCurlClass/ &
|
||||
elif [[ "${TRAVIS_PHP_VERSION}" == "7.1" ]]; then
|
||||
@@ -63,6 +93,7 @@ EOF
|
||||
sudo service nginx stop
|
||||
sleep 5
|
||||
sudo service nginx start
|
||||
phpunit_shim
|
||||
elif [[ "${TRAVIS_PHP_VERSION}" == "nightly" ]]; then
|
||||
php -S 127.0.0.1:8000 -t tests/PHPCurlClass/ &
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user