diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..e17afb1 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,33 @@ +name: CI + +on: + push: + pull_request: + +jobs: + test: + name: "PHPUnit: PHP ${{ matrix.php }}" + + strategy: + matrix: + include: + - php: '8.0' + - php: '8.1' + + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + tools: composer + + - name: Install dependencies + run: composer install + + - name: Run tests + run: composer phpunit diff --git a/.scrutinizer.yml b/.scrutinizer.yml deleted file mode 100644 index 59edd54..0000000 --- a/.scrutinizer.yml +++ /dev/null @@ -1,27 +0,0 @@ -filter: - excluded_paths: - - 'vendor/*' - -tools: - php_mess_detector: - config: - controversial_rules: { superglobals: false } - php_sim: true - php_cpd: true - php_pdepend: true - php_code_coverage: false - php_code_sniffer: true - php_cs_fixer: true - php_loc: true - php_analyzer: true - sensiolabs_security_checker: true - external_code_coverage: - timeout: '900' - -checks: - php: - psr2_class_declaration: false - psr2_switch_declaration: false - sql_injection_vulnerabilities: true - security_vulnerabilities: true - no_eval: true \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index d31f079..0000000 --- a/.travis.yml +++ /dev/null @@ -1,18 +0,0 @@ -language: php - -matrix: - include: - - env: TYPE=coverage - php: 5.6 - - env: TYPE=UNIT; - php: 5.4 - - env: TYPE=UNIT; - php: 5.3 - - env: TYPE=UNIT; - php: hhvm - -script: - - bash ./tests/travis/run-tests.sh - -after_success: - - bash ./tests/travis/upload-coverage-report.sh diff --git a/README.md b/README.md index 17c3a09..b31bc66 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,6 @@ # Http request -[![Build Status](https://secure.travis-ci.org/onoi/http-request.svg?branch=master)](http://travis-ci.org/onoi/http-request) -[![Code Coverage](https://scrutinizer-ci.com/g/onoi/http-request/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/onoi/http-request/?branch=master) -[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/onoi/http-request/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/onoi/http-request/?branch=master) +[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/onoi/http-request/CI)](https://github.com/onoi/http-request/actions?query=workflow%3ACI) [![Latest Stable Version](https://poser.pugx.org/onoi/http-request/version.png)](https://packagist.org/packages/onoi/http-request) [![Packagist download count](https://poser.pugx.org/onoi/http-request/d/total.png)](https://packagist.org/packages/onoi/http-request) [![Dependency Status](https://www.versioneye.com/php/onoi:http-request/badge.png)](https://www.versioneye.com/php/onoi:http-request) @@ -20,7 +18,7 @@ This library provides: ## Requirements -- PHP 5.3 or later +- PHP 8.0 or later ## Installation @@ -30,7 +28,7 @@ dependency to your [composer.json][composer]. ```json { "require": { - "onoi/http-request": "~1.3" + "onoi/http-request": "~2.0" } } ``` @@ -114,6 +112,9 @@ The library provides unit tests that covers the core-functionality normally run ## Release notes +* 2.0.0 (Under development) + - Increased minimum PHP requirement to 8.0 + * 1.3.1 (2016-01-14) - Extended `SocketRequest` to match a possible TLS port diff --git a/composer.json b/composer.json index 435ac40..ab94077 100644 --- a/composer.json +++ b/composer.json @@ -15,11 +15,11 @@ } ], "require": { - "php": ">=5.3.2", + "php": ">=8.0", "onoi/cache": "~1.2" }, "suggest": { - "lib-curl": "Allows making CURL requests" + "lib-curl": "Allows making CURL requests" }, "extra": { "branch-alias": { @@ -31,10 +31,19 @@ "Onoi\\HttpRequest\\": "src/" } }, + "autoload-dev": { + "psr-4": { + "Onoi\\HttpRequest\\Tests\\": "tests/phpunit/Unit", + "Onoi\\HttpRequest\\Tests\\Integration\\": "tests/phpunit/Integration" + } + }, "config": { "process-timeout": 0 }, "scripts":{ "phpunit": "phpunit -c phpunit.xml.dist" + }, + "require-dev": { + "phpunit/phpunit": "^9.5" } } diff --git a/phpunit.xml.dist b/phpunit.xml.dist index de5e1ce..e7105fb 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,7 +1,7 @@ - + + verbose="true" + xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"> + + + src + + tests/phpunit/Unit @@ -19,14 +25,9 @@ tests/phpunit/Integration - - - src - - - - - + + + diff --git a/src/CachedCurlRequest.php b/src/CachedCurlRequest.php index 5fe4fac..bc60b9c 100644 --- a/src/CachedCurlRequest.php +++ b/src/CachedCurlRequest.php @@ -2,6 +2,7 @@ namespace Onoi\HttpRequest; +use CurlHandle; use Onoi\Cache\Cache; /** @@ -32,11 +33,8 @@ class CachedCurlRequest extends CurlRequest { /** * @since 1.0 - * - * @param resource $handle - * @param Cache $cache */ - public function __construct( $handle, Cache $cache ) { + public function __construct( CurlHandle|false $handle, Cache $cache ) { parent::__construct( $handle ); $this->cache = $cache; diff --git a/src/CurlRequest.php b/src/CurlRequest.php index afda0cd..aa2ac03 100644 --- a/src/CurlRequest.php +++ b/src/CurlRequest.php @@ -2,6 +2,7 @@ namespace Onoi\HttpRequest; +use CurlHandle; use InvalidArgumentException; /** @@ -12,10 +13,7 @@ */ class CurlRequest implements HttpRequest { - /** - * @var resource - */ - private $handle; + private CurlHandle $handle; /** * @var array @@ -24,12 +22,10 @@ class CurlRequest implements HttpRequest { /** * @since 1.0 - * - * @param resource $handle */ - public function __construct( $handle ) { + public function __construct( CurlHandle|false $handle ) { - if ( get_resource_type( $handle ) !== 'curl' ) { + if ( $handle === false ) { throw new InvalidArgumentException( "Expected a cURL resource type" ); } diff --git a/src/MultiCurlRequest.php b/src/MultiCurlRequest.php index 212d218..037577b 100644 --- a/src/MultiCurlRequest.php +++ b/src/MultiCurlRequest.php @@ -2,8 +2,9 @@ namespace Onoi\HttpRequest; -use InvalidArgumentException; use Closure; +use CurlMultiHandle; +use InvalidArgumentException; /** * @license GNU GPL v2+ @@ -13,10 +14,7 @@ */ class MultiCurlRequest implements HttpRequest { - /** - * @var resource - */ - private $handle; + private CurlMultiHandle $handle; /** * @var array @@ -35,13 +33,11 @@ class MultiCurlRequest implements HttpRequest { /** * @since 1.0 - * - * @param resource $handle */ - public function __construct( $handle ) { + public function __construct( CurlMultiHandle|false $handle ) { - if ( get_resource_type( $handle ) !== 'curl_multi' ) { - throw new InvalidArgumentException( "Expected a cURL multi resource type" ); + if ( $handle === false ) { + throw new InvalidArgumentException( "Expected a cURL resource type" ); } $this->handle = $handle; diff --git a/tests/bootstrap.php b/tests/bootstrap.php deleted file mode 100644 index fd2d767..0000000 --- a/tests/bootstrap.php +++ /dev/null @@ -1,27 +0,0 @@ -addPsr4( 'Onoi\\HttpRequest\\Tests\\', __DIR__ . '/phpunit/Unit' ); -$autoLoader->addPsr4( 'Onoi\\HttpRequest\\Tests\\Integration\\', __DIR__ . '/phpunit/Integration' ); diff --git a/tests/phpunit/Integration/RequestToExternalUrlTest.php b/tests/phpunit/Integration/RequestToExternalUrlTest.php index 0e9ed8e..6a9b28e 100644 --- a/tests/phpunit/Integration/RequestToExternalUrlTest.php +++ b/tests/phpunit/Integration/RequestToExternalUrlTest.php @@ -14,7 +14,7 @@ * * @author mwjames */ -class RequestToExternalUrlTest extends \PHPUnit_Framework_TestCase { +class RequestToExternalUrlTest extends \PHPUnit\Framework\TestCase { public function testCachedRequestToExternalUrl() { @@ -35,8 +35,7 @@ public function testCachedRequestToExternalUrl() { $instance->setOption( ONOI_HTTP_REQUEST_RESPONSECACHE_TTL, 42 ); $instance->setOption( ONOI_HTTP_REQUEST_RESPONSECACHE_PREFIX, 'foo' ); - $this->assertInternalType( - 'string', + $this->assertIsString( $instance->execute() ); diff --git a/tests/phpunit/Integration/RequestToPhpHttpdTest.php b/tests/phpunit/Integration/RequestToPhpHttpdTest.php index b9a96ec..f8cbb2f 100644 --- a/tests/phpunit/Integration/RequestToPhpHttpdTest.php +++ b/tests/phpunit/Integration/RequestToPhpHttpdTest.php @@ -14,7 +14,7 @@ * * @author mwjames */ -class RequestToPhpHttpdTest extends \PHPUnit_Framework_TestCase { +class RequestToPhpHttpdTest extends \PHPUnit\Framework\TestCase { private static $pid; @@ -25,7 +25,7 @@ class RequestToPhpHttpdTest extends \PHPUnit_Framework_TestCase { * Options defined in phpunit.xml.dist * @see https://github.com/vgno/tech.vg.no-1812/blob/master/features/bootstrap/FeatureContext.php */ - public static function setUpBeforeClass() { + public static function setUpBeforeClass(): void { $command = sprintf( 'php -S %s:%d -t %s >/dev/null 2>&1 & echo $!', WEB_SERVER_HOST, @@ -39,7 +39,7 @@ public static function setUpBeforeClass() { self::$pid = (int) $output[0]; } - public static function tearDownAfterClass() { + public static function tearDownAfterClass(): void { // exec( 'kill ' . (int) self::$pid ); } diff --git a/tests/phpunit/Unit/CachedCurlRequestTest.php b/tests/phpunit/Unit/CachedCurlRequestTest.php index d62a0b6..52557dc 100644 --- a/tests/phpunit/Unit/CachedCurlRequestTest.php +++ b/tests/phpunit/Unit/CachedCurlRequestTest.php @@ -13,7 +13,7 @@ * * @author mwjames */ -class CachedCurlRequestTest extends \PHPUnit_Framework_TestCase { +class CachedCurlRequestTest extends \PHPUnit\Framework\TestCase { public function testCanConstruct() { @@ -72,13 +72,12 @@ public function testDifferentOptionsToGenerateDifferentKeys() { ->setMethods( array( 'contains' ) ) ->getMockForAbstractClass(); - $cache->expects( $this->at( 0 ) ) + $cache->expects( $this->exactly( 2 ) ) ->method( 'contains' ) - ->with( $this->equalTo( 'onoi:http:7ccbcfd552a597d67077d6cc037580ac' ) ); - - $cache->expects( $this->at( 1 ) ) - ->method( 'contains' ) - ->with( $this->equalTo( 'onoi:http:e2015ad4244c4663f10f305e299d5c4f' ) ); + ->withConsecutive( + [ $this->equalTo( 'onoi:http:7ccbcfd552a597d67077d6cc037580ac' ) ], + [ $this->equalTo( 'onoi:http:e2015ad4244c4663f10f305e299d5c4f' ) ] + ); $instance = new CachedCurlRequest( curl_init(), $cache ); @@ -96,13 +95,12 @@ public function testToHaveTargetUrlAsPartOfTheCacheKey() { ->setMethods( array( 'contains', 'save' ) ) ->getMockForAbstractClass(); - $cache->expects( $this->at( 0 ) ) - ->method( 'contains' ) - ->with( $this->equalTo( 'onoi:http:236b194825be3d614ce5fc1b7763a278' ) ); - - $cache->expects( $this->at( 2 ) ) + $cache->expects( $this->exactly( 2 ) ) ->method( 'contains' ) - ->with( $this->equalTo( 'onoi:http:823a603f972819c10d13f32b14460573' ) ); + ->withConsecutive( + [ $this->equalTo( 'onoi:http:236b194825be3d614ce5fc1b7763a278' ) ], + [ $this->equalTo( 'onoi:http:823a603f972819c10d13f32b14460573' ) ] + ); $instance = new CachedCurlRequest( curl_init( 'http://example.org' ), $cache ); diff --git a/tests/phpunit/Unit/CurlRequestTest.php b/tests/phpunit/Unit/CurlRequestTest.php index 5af5a89..1ca1252 100644 --- a/tests/phpunit/Unit/CurlRequestTest.php +++ b/tests/phpunit/Unit/CurlRequestTest.php @@ -3,6 +3,7 @@ namespace Onoi\HttpRequest\Tests; use Onoi\HttpRequest\CurlRequest; +use TypeError; /** * @covers \Onoi\HttpRequest\CurlRequest @@ -13,7 +14,7 @@ * * @author mwjames */ -class CurlRequestTest extends \PHPUnit_Framework_TestCase { +class CurlRequestTest extends \PHPUnit\Framework\TestCase { public function testCanConstruct() { @@ -31,7 +32,7 @@ public function testCanConstruct() { } public function testWrongResourceTypeThrowsException() { - $this->setExpectedException( 'InvalidArgumentException' ); + $this->expectException( TypeError::class ); new CurlRequest( curl_multi_init() ); } @@ -45,8 +46,7 @@ public function testPing() { $instance->setOption( CURLOPT_URL, 'http://example.org' ); - $this->assertInternalType( - 'boolean', + $this->assertIsBool( $instance->ping() ); } @@ -55,8 +55,7 @@ public function testGetLastError() { $instance = new CurlRequest( curl_init() ); - $this->assertInternalType( - 'string', + $this->assertIsString( $instance->getLastError() ); } @@ -65,8 +64,7 @@ public function testGetLastErrorCode() { $instance = new CurlRequest( curl_init() ); - $this->assertInternalType( - 'integer', + $this->assertIsInt( $instance->getLastErrorCode() ); } diff --git a/tests/phpunit/Unit/Exception/BadHttpResponseExceptionTest.php b/tests/phpunit/Unit/Exception/BadHttpResponseExceptionTest.php index 5a6646f..114c219 100644 --- a/tests/phpunit/Unit/Exception/BadHttpResponseExceptionTest.php +++ b/tests/phpunit/Unit/Exception/BadHttpResponseExceptionTest.php @@ -14,11 +14,11 @@ * * @author mwjames */ -class BadHttpResponseExceptionTest extends \PHPUnit_Framework_TestCase { +class BadHttpResponseExceptionTest extends \PHPUnit\Framework\TestCase { private $httpRequest; - protected function setUp() { + protected function setUp(): void { parent::setUp(); $this->httpRequest = $this->getMockBuilder( '\Onoi\HttpRequest\HttpRequest' ) @@ -73,7 +73,7 @@ public function testForCurlRequest() { $e = new BadHttpResponseException( $curlRequest ); - $this->assertContains( + $this->assertStringContainsString( 'error 3', $e->getMessage() ); diff --git a/tests/phpunit/Unit/Exception/HttpConnectionExceptionTest.php b/tests/phpunit/Unit/Exception/HttpConnectionExceptionTest.php index 7da630f..9105a2b 100644 --- a/tests/phpunit/Unit/Exception/HttpConnectionExceptionTest.php +++ b/tests/phpunit/Unit/Exception/HttpConnectionExceptionTest.php @@ -14,7 +14,7 @@ * * @author mwjames */ -class HttpConnectionExceptionTest extends \PHPUnit_Framework_TestCase { +class HttpConnectionExceptionTest extends \PHPUnit\Framework\TestCase { public function testCanConstruct() { @@ -28,7 +28,7 @@ public function testErrorMessage() { $e = new HttpConnectionException( 'foo', 42 ); - $this->assertContains( + $this->assertStringContainsString( 'foo', $e->getMessage() ); diff --git a/tests/phpunit/Unit/HttpRequestFactoryTest.php b/tests/phpunit/Unit/HttpRequestFactoryTest.php index 9fe4767..1b120a2 100644 --- a/tests/phpunit/Unit/HttpRequestFactoryTest.php +++ b/tests/phpunit/Unit/HttpRequestFactoryTest.php @@ -13,7 +13,7 @@ * * @author mwjames */ -class HttpRequestFactoryTest extends \PHPUnit_Framework_TestCase { +class HttpRequestFactoryTest extends \PHPUnit\Framework\TestCase { public function testCanConstruct() { diff --git a/tests/phpunit/Unit/MockedHttpStreamSocketRequestTest.php b/tests/phpunit/Unit/MockedHttpStreamSocketRequestTest.php index 3174739..1034c00 100644 --- a/tests/phpunit/Unit/MockedHttpStreamSocketRequestTest.php +++ b/tests/phpunit/Unit/MockedHttpStreamSocketRequestTest.php @@ -13,15 +13,15 @@ * * @author mwjames */ -class MockedHttpStreamSocketRequestTest extends \PHPUnit_Framework_TestCase { +class MockedHttpStreamSocketRequestTest extends \PHPUnit\Framework\TestCase { - public function setUp() { + public function setUp(): void { parent::setUp(); stream_wrapper_unregister( 'http' ); $return = stream_wrapper_register( 'http', - 'Onoi\HttpRequest\Tests\MockHttpStreamWrapper' + MockHttpStreamWrapper::class ); if ( !$return ) { @@ -44,7 +44,7 @@ public function getMockStream( $data, $code = 'HTTP/1.1 200 OK' ) { return fopen( 'http://example.com', 'r', false, $context ); } - public function tearDown() { + public function tearDown(): void { stream_wrapper_restore('http'); } diff --git a/tests/phpunit/Unit/MultiCurlRequestTest.php b/tests/phpunit/Unit/MultiCurlRequestTest.php index f85698b..902aa85 100644 --- a/tests/phpunit/Unit/MultiCurlRequestTest.php +++ b/tests/phpunit/Unit/MultiCurlRequestTest.php @@ -4,6 +4,7 @@ use Onoi\HttpRequest\MultiCurlRequest; use Onoi\HttpRequest\CurlRequest; +use TypeError; /** * @covers \Onoi\HttpRequest\MultiCurlRequest @@ -14,7 +15,7 @@ * * @author mwjames */ -class MultiCurlRequestTest extends \PHPUnit_Framework_TestCase { +class MultiCurlRequestTest extends \PHPUnit\Framework\TestCase { public function testCanConstruct() { @@ -32,7 +33,7 @@ public function testCanConstruct() { } public function testWrongResourceTypeThrowsException() { - $this->setExpectedException( 'InvalidArgumentException' ); + $this->expectException( TypeError::class ); new MultiCurlRequest( curl_init() ); } @@ -98,13 +99,11 @@ public function testExecuteForResponse() { new CurlRequest( curl_init() ) ); - $this->assertInternalType( - 'array', + $this->assertIsArray( $instance->execute() ); - $this->assertInternalType( - 'string', + $this->assertIsString( $instance->getLastError() ); @@ -124,7 +123,7 @@ public function testDeprecatedSetCallback() { $requestResponse = null; - $instance->setCallback( function( $requestResponseCompleted ) use ( &$requestResponse ) { + $instance->setCallback( function( $requestResponseCompleted ) use ( &$requestResponse ): void { $requestResponse = $requestResponseCompleted; } ); @@ -143,7 +142,7 @@ public function testOnCompletedCallback() { $requestResponse = null; - $instance->setOption( ONOI_HTTP_REQUEST_ON_COMPLETED_CALLBACK, function( $requestResponseCompleted ) use ( &$requestResponse ) { + $instance->setOption( ONOI_HTTP_REQUEST_ON_COMPLETED_CALLBACK, function( $requestResponseCompleted ) use ( &$requestResponse ): void { $requestResponse = $requestResponseCompleted; } ); @@ -157,7 +156,7 @@ public function testOnCompletedCallback() { $this->assertRequestResponse( $requestResponse ); } - private function assertRequestResponse( $requestResponse ) { + private function assertRequestResponse( $requestResponse ): void { $this->assertInstanceOf( '\Onoi\HttpRequest\RequestResponse', @@ -174,7 +173,7 @@ private function assertRequestResponse( $requestResponse ) { } } - public function pingConnectionStateProvider() { + public function pingConnectionStateProvider(): array { $provider[] = array( true diff --git a/tests/phpunit/Unit/NullRequestTest.php b/tests/phpunit/Unit/NullRequestTest.php index 03c3065..d4f8729 100644 --- a/tests/phpunit/Unit/NullRequestTest.php +++ b/tests/phpunit/Unit/NullRequestTest.php @@ -13,7 +13,7 @@ * * @author mwjames */ -class NullRequestTest extends \PHPUnit_Framework_TestCase { +class NullRequestTest extends \PHPUnit\Framework\TestCase { public function testCanConstruct() { @@ -34,38 +34,31 @@ public function testNull() { $instance = new NullRequest(); - $this->assertInternalType( - 'boolean', + $this->assertIsBool( $instance->ping() ); - $this->assertInternalType( - 'null', + $this->assertNull( $instance->setOption( 'foo', 42 ) ); - $this->assertInternalType( - 'null', + $this->assertNull( $instance->getOption( 'foo' ) ); - $this->assertInternalType( - 'null', + $this->assertNull( $instance->getLastTransferInfo() ); - $this->assertInternalType( - 'string', + $this->assertIsString( $instance->getLastError() ); - $this->assertInternalType( - 'integer', + $this->assertIsInt( $instance->getLastErrorCode() ); - $this->assertInternalType( - 'null', + $this->assertNull( $instance->execute() ); } diff --git a/tests/phpunit/Unit/RequestResponseTest.php b/tests/phpunit/Unit/RequestResponseTest.php index 99b616a..4231945 100644 --- a/tests/phpunit/Unit/RequestResponseTest.php +++ b/tests/phpunit/Unit/RequestResponseTest.php @@ -2,6 +2,7 @@ namespace Onoi\HttpRequest\Tests; +use InvalidArgumentException; use Onoi\HttpRequest\RequestResponse; /** @@ -13,7 +14,7 @@ * * @author mwjames */ -class RequestResponseTest extends \PHPUnit_Framework_TestCase { +class RequestResponseTest extends \PHPUnit\Framework\TestCase { public function testCanConstruct() { @@ -43,8 +44,7 @@ public function testSetGetValue() { $instance->getList() ); - $this->assertInternalType( - 'string', + $this->assertIsString( $instance->asJsonString() ); } @@ -53,7 +53,7 @@ public function testUnregisteredKeyThrowsException() { $instance = new RequestResponse(); - $this->setExpectedException( 'InvalidArgumentException' ); + $this->expectException( InvalidArgumentException::class ); $instance->get( 'Foo' ); } diff --git a/tests/phpunit/Unit/SocketRequestTest.php b/tests/phpunit/Unit/SocketRequestTest.php index 1fe34a0..bfa9233 100644 --- a/tests/phpunit/Unit/SocketRequestTest.php +++ b/tests/phpunit/Unit/SocketRequestTest.php @@ -13,7 +13,7 @@ * * @author mwjames */ -class SocketRequestTest extends \PHPUnit_Framework_TestCase { +class SocketRequestTest extends \PHPUnit\Framework\TestCase { public function testCanConstruct() { @@ -40,8 +40,7 @@ public function testPing() { $instance->setOption( ONOI_HTTP_REQUEST_URL, 'http://example.org' ); - $this->assertInternalType( - 'boolean', + $this->assertIsBool( $instance->ping() ); } @@ -52,8 +51,7 @@ public function testExecute() { $instance->setOption( ONOI_HTTP_REQUEST_CONNECTION_TIMEOUT, 1 ); $instance->setOption( ONOI_HTTP_REQUEST_URL, 'http://localhost:8888' ); - $this->assertInternalType( - 'boolean', + $this->assertIsBool( $instance->execute() ); } @@ -65,8 +63,7 @@ public function testGetLastError() { $instance->execute(); - $this->assertInternalType( - 'string', + $this->assertIsString( $instance->getLastError() ); } @@ -75,8 +72,7 @@ public function testGetLastErrorCode() { $instance = new SocketRequest(); - $this->assertInternalType( - 'integer', + $this->assertIsInt( $instance->getLastErrorCode() ); } @@ -85,8 +81,7 @@ public function testGetLastTransferInfo() { $instance = new SocketRequest(); - $this->assertInternalType( - 'string', + $this->assertIsString( $instance->getLastTransferInfo() ); } @@ -98,7 +93,7 @@ public function testCallbackOnRequestNotCompleted() { $requestResponse = null; - $instance->setOption( ONOI_HTTP_REQUEST_ON_FAILED_CALLBACK, function( $requestResponseFailed ) use ( &$requestResponse ) { + $instance->setOption( ONOI_HTTP_REQUEST_ON_FAILED_CALLBACK, function( $requestResponseFailed ) use ( &$requestResponse ): void { $requestResponse = $requestResponseFailed; } ); @@ -121,7 +116,7 @@ public function testCallbackOnRequestCompleted() { $requestResponse = null; - $instance->setOption( ONOI_HTTP_REQUEST_ON_COMPLETED_CALLBACK, function( $requestResponseCompleted ) use ( &$requestResponse ) { + $instance->setOption( ONOI_HTTP_REQUEST_ON_COMPLETED_CALLBACK, function( $requestResponseCompleted ) use ( &$requestResponse ): void { $requestResponse = $requestResponseCompleted; } ); @@ -149,7 +144,7 @@ public function testCallbackOnRequestFailed() { $requestResponse = null; - $instance->setOption( ONOI_HTTP_REQUEST_ON_FAILED_CALLBACK, function( $requestResponseFailed ) use ( &$requestResponse ) { + $instance->setOption( ONOI_HTTP_REQUEST_ON_FAILED_CALLBACK, function( $requestResponseFailed ) use ( &$requestResponse ): void { $requestResponse = $requestResponseFailed; } ); @@ -167,7 +162,7 @@ public function testCallbackOnRequestNotAccepted() { $requestResponse = null; - $instance->setOption( ONOI_HTTP_REQUEST_ON_FAILED_CALLBACK, function( $requestResponseFailed ) use ( &$requestResponse ) { + $instance->setOption( ONOI_HTTP_REQUEST_ON_FAILED_CALLBACK, function( $requestResponseFailed ) use ( &$requestResponse ): void { $requestResponse = $requestResponseFailed; } ); diff --git a/tests/travis/run-tests.sh b/tests/travis/run-tests.sh deleted file mode 100644 index 8f032fb..0000000 --- a/tests/travis/run-tests.sh +++ /dev/null @@ -1,15 +0,0 @@ -#! /bin/bash -set -ex - -BASE_PATH=$(pwd) - -if [ "$TYPE" == "coverage" ] -then - composer install - composer validate --no-interaction - composer phpunit -- --coverage-clover $BASE_PATH/build/coverage.clover -else - composer install - composer validate --no-interaction - composer phpunit -fi diff --git a/tests/travis/upload-coverage-report.sh b/tests/travis/upload-coverage-report.sh deleted file mode 100644 index aff95cf..0000000 --- a/tests/travis/upload-coverage-report.sh +++ /dev/null @@ -1,10 +0,0 @@ -#! /bin/bash -set -ex - -BASE_PATH=$(pwd) - -if [ "$TYPE" == "coverage" ] -then - wget https://scrutinizer-ci.com/ocular.phar - php ocular.phar code-coverage:upload --format=php-clover $BASE_PATH/build/coverage.clover -fi \ No newline at end of file