diff -Nru google-recaptcha-1.2.4/.gitattributes google-recaptcha-1.3.0/.gitattributes --- google-recaptcha-1.2.4/.gitattributes 1970-01-01 00:00:00.000000000 +0000 +++ google-recaptcha-1.3.0/.gitattributes 2023-02-18 17:41:46.000000000 +0000 @@ -0,0 +1,10 @@ +/.github export-ignore +/examples export-ignore +/tests export-ignore +/.gitattributes export-ignore +/.gitignore export-ignore +/.travis.yml export-ignore +/app.yml export-ignore +/ARCHITECTURE.md export-ignore +/CONTRIBUTING.md export-ignore +/phpunit.xml.dist export-ignore \ No newline at end of file diff -Nru google-recaptcha-1.2.4/.gitignore google-recaptcha-1.3.0/.gitignore --- google-recaptcha-1.2.4/.gitignore 2020-03-31 17:50:54.000000000 +0000 +++ google-recaptcha-1.3.0/.gitignore 2023-02-18 17:41:46.000000000 +0000 @@ -1,5 +1,6 @@ /.php_cs.cache /.phpunit.result.cache +.phpunit.cache/ /build /composer.lock /examples/config.php diff -Nru google-recaptcha-1.2.4/.travis.yml google-recaptcha-1.3.0/.travis.yml --- google-recaptcha-1.2.4/.travis.yml 2020-03-31 17:50:54.000000000 +0000 +++ google-recaptcha-1.3.0/.travis.yml 2023-02-18 17:41:46.000000000 +0000 @@ -1,16 +1,19 @@ -dist: trusty +dist: xenial language: php -sudo: false - php: - - '5.5' - '5.6' - '7.0' - '7.1' - '7.2' - '7.3' + - '7.4' + +matrix: + include: + - php: 5.5 + dist: trusty before_script: - composer install diff -Nru google-recaptcha-1.2.4/README.md google-recaptcha-1.3.0/README.md --- google-recaptcha-1.2.4/README.md 2020-03-31 17:50:54.000000000 +0000 +++ google-recaptcha-1.3.0/README.md 2023-02-18 17:41:46.000000000 +0000 @@ -13,7 +13,7 @@ - reCAPTCHA: https://www.google.com/recaptcha - This repo: https://github.com/google/recaptcha - Hosted demo: https://recaptcha-demo.appspot.com/ -- Version: 1.2.4 +- Version: 1.3.0 - License: BSD, see [LICENSE](LICENSE) ## Installation @@ -26,17 +26,22 @@ Run the following command from your project directory to add the dependency: ```sh -composer require google/recaptcha "^1.2" +composer require google/recaptcha "^1.3" ``` Alternatively, add the dependency directly to your `composer.json` file: ```json "require": { - "google/recaptcha": "^1.2" + "google/recaptcha": "^1.3" } ``` +### Support for earlier versions of PHP + +The 1.3 release moves to PHP 8 and up. For earlier versions, you will need to +stay with the 1.2 releases. + ### Direct download Download the [ZIP file](https://github.com/google/recaptcha/archive/master.zip) @@ -66,7 +71,9 @@ side you need the response from the reCAPTCHA service and secret key from your credentials. Instantiate the `ReCaptcha` class with your secret key, specify any additional validation rules, and then call `verify()` with the reCAPTCHA -response and user's IP address. For example: +response (usually in `$_POST['g-recaptcha-response']` or the response from +`grecaptcha.execute()` in JS which is in `$gRecaptchaResponse` in the example) +and user's IP address. For example: ```php =5.5" + "php": ">=8" }, "require-dev": { - "phpunit/phpunit": "^4.8.36|^5.7.27|^6.59|^7.5.11", - "friendsofphp/php-cs-fixer": "^2.2.20|^2.15", - "php-coveralls/php-coveralls": "^2.1" + "phpunit/phpunit": "^10", + "friendsofphp/php-cs-fixer": "^3.14", + "php-coveralls/php-coveralls": "^2.5" }, "autoload": { "psr-4": { @@ -24,13 +24,13 @@ }, "extra": { "branch-alias": { - "dev-master": "1.2.x-dev" + "dev-master": "1.3.x-dev" } }, "scripts": { - "lint": "vendor/bin/php-cs-fixer -vvv fix --using-cache=no --dry-run .", - "lint-fix": "vendor/bin/php-cs-fixer -vvv fix --using-cache=no .", - "test": "vendor/bin/phpunit --colors=always", + "lint": "PHP_CS_FIXER_IGNORE_ENV=1 vendor/bin/php-cs-fixer -vvv fix --using-cache=no --dry-run .", + "lint-fix": "PHP_CS_FIXER_IGNORE_ENV=1 vendor/bin/php-cs-fixer -vvv fix --using-cache=no .", + "test": "XDEBUG_MODE=coverage vendor/bin/phpunit", "serve-examples": "@php -S localhost:8080 -t examples" }, "config": { diff -Nru google-recaptcha-1.2.4/debian/changelog google-recaptcha-1.3.0/debian/changelog --- google-recaptcha-1.2.4/debian/changelog 2023-04-26 13:47:29.000000000 +0000 +++ google-recaptcha-1.3.0/debian/changelog 2024-04-19 23:00:36.000000000 +0000 @@ -1,8 +1,18 @@ -google-recaptcha (1.2.4-5+jammy1) jammy; urgency=medium +google-recaptcha (1.3.0-1+jammy1) jammy; urgency=medium - * All changes from 1.2.4-5 + * No changes from 1.3.0-1 - -- William Desportes Wed, 26 Apr 2023 15:47:29 +0200 + -- William Desportes Sat, 20 Apr 2024 01:00:36 +0200 + +google-recaptcha (1.3.0-1) unstable; urgency=medium + + * Switch to mode=git since upstream gitattributes removed the test folder + * Update gbp.conf filter + * New upstream version 1.3.0 + * Drop phpunit 9 patches + * Update examples patch + + -- William Desportes Fri, 16 Jun 2023 23:54:18 +0200 google-recaptcha (1.2.4-5) unstable; urgency=medium diff -Nru google-recaptcha-1.2.4/debian/gbp.conf google-recaptcha-1.3.0/debian/gbp.conf --- google-recaptcha-1.2.4/debian/gbp.conf 2021-01-19 12:39:21.000000000 +0000 +++ google-recaptcha-1.3.0/debian/gbp.conf 2024-04-19 23:00:24.000000000 +0000 @@ -2,6 +2,8 @@ pristine-tar = True patch-numbers = False debian-branch = debian/latest +# Remove dev files +filter = [ '.gitattributes', '.travis.yml', '.github' ] [dch] full = True diff -Nru google-recaptcha-1.2.4/debian/patches/Adapt-to-recent-version-of-PHPUnit-9.patch google-recaptcha-1.3.0/debian/patches/Adapt-to-recent-version-of-PHPUnit-9.patch --- google-recaptcha-1.2.4/debian/patches/Adapt-to-recent-version-of-PHPUnit-9.patch 2021-01-19 12:39:21.000000000 +0000 +++ google-recaptcha-1.3.0/debian/patches/Adapt-to-recent-version-of-PHPUnit-9.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ -From: =?utf-8?q?David_Pr=C3=A9vot?= -Date: Wed, 30 Dec 2020 10:59:36 +0100 -Subject: Adapt to recent version of PHPUnit (9) - -Bug-Debian: https://bugs.debian.org/978381 -Forwarded: not-needed ---- - tests/ReCaptcha/ReCaptchaTest.php | 2 +- - tests/ReCaptcha/RequestMethod/PostTest.php | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -diff --git a/tests/ReCaptcha/ReCaptchaTest.php b/tests/ReCaptcha/ReCaptchaTest.php -index ddb16f0..6a90d9e 100644 ---- a/tests/ReCaptcha/ReCaptchaTest.php -+++ b/tests/ReCaptcha/ReCaptchaTest.php -@@ -40,11 +40,11 @@ class ReCaptchaTest extends TestCase - { - - /** -- * @expectedException \RuntimeException - * @dataProvider invalidSecretProvider - */ - public function testExceptionThrownOnInvalidSecret($invalid) - { -+ $this->expectException('\RuntimeException'); - $rc = new ReCaptcha($invalid); - } - -diff --git a/tests/ReCaptcha/RequestMethod/PostTest.php b/tests/ReCaptcha/RequestMethod/PostTest.php -index bdfb78e..88a298d 100644 ---- a/tests/ReCaptcha/RequestMethod/PostTest.php -+++ b/tests/ReCaptcha/RequestMethod/PostTest.php -@@ -115,7 +115,7 @@ class PostTest extends TestCase - 'Content-type: application/x-www-form-urlencoded', - ); - foreach ($headers as $header) { -- $this->assertContains($header, $options['http']['header']); -+ $this->assertStringContainsString($header, $options['http']['header']); - } - } - diff -Nru google-recaptcha-1.2.4/debian/patches/Set-php-type-hints-for-phpunit.patch google-recaptcha-1.3.0/debian/patches/Set-php-type-hints-for-phpunit.patch --- google-recaptcha-1.2.4/debian/patches/Set-php-type-hints-for-phpunit.patch 2021-01-14 17:04:05.000000000 +0000 +++ google-recaptcha-1.3.0/debian/patches/Set-php-type-hints-for-phpunit.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -From: William Desportes -Date: Sat, 2 Jan 2021 19:17:39 +0100 -Subject: Make tests compatible with recent versions of phpunit - -Forwarded: not-needed ---- - tests/ReCaptcha/RequestMethod/CurlPostTest.php | 2 +- - tests/ReCaptcha/RequestMethod/PostTest.php | 4 ++-- - 2 files changed, 3 insertions(+), 3 deletions(-) - -diff --git a/tests/ReCaptcha/RequestMethod/CurlPostTest.php b/tests/ReCaptcha/RequestMethod/CurlPostTest.php -index 8fb17dc..bddf4aa 100644 ---- a/tests/ReCaptcha/RequestMethod/CurlPostTest.php -+++ b/tests/ReCaptcha/RequestMethod/CurlPostTest.php -@@ -40,7 +40,7 @@ use PHPUnit\Framework\TestCase; - - class CurlPostTest extends TestCase - { -- protected function setUp() -+ protected function setUp(): void - { - if (!extension_loaded('curl')) { - $this->markTestSkipped( -diff --git a/tests/ReCaptcha/RequestMethod/PostTest.php b/tests/ReCaptcha/RequestMethod/PostTest.php -index 88a298d..592185d 100644 ---- a/tests/ReCaptcha/RequestMethod/PostTest.php -+++ b/tests/ReCaptcha/RequestMethod/PostTest.php -@@ -44,12 +44,12 @@ class PostTest extends TestCase - protected $parameters = null; - protected $runcount = 0; - -- public function setUp() -+ public function setUp(): void - { - $this->parameters = new RequestParameters('secret', 'response', 'remoteip', 'version'); - } - -- public function tearDown() -+ public function tearDown(): void - { - self::$assert = null; - } diff -Nru google-recaptcha-1.2.4/debian/patches/Updates-examples-autoload-require-path.patch google-recaptcha-1.3.0/debian/patches/Updates-examples-autoload-require-path.patch --- google-recaptcha-1.2.4/debian/patches/Updates-examples-autoload-require-path.patch 2021-01-14 17:03:52.000000000 +0000 +++ google-recaptcha-1.3.0/debian/patches/Updates-examples-autoload-require-path.patch 2024-04-19 23:00:24.000000000 +0000 @@ -13,7 +13,7 @@ 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/recaptcha-content-security-policy.php b/examples/recaptcha-content-security-policy.php -index aaf7eb2..76f2f7c 100644 +index 86dcdbd..36d9a10 100644 --- a/examples/recaptcha-content-security-policy.php +++ b/examples/recaptcha-content-security-policy.php @@ -35,7 +35,7 @@ require __DIR__ . '/appengine-https.php'; @@ -26,7 +26,7 @@ // This example shows the use of a Content Security Policy // https://developers.google.com/web/fundamentals/security/csp/ diff --git a/examples/recaptcha-v2-checkbox-explicit.php b/examples/recaptcha-v2-checkbox-explicit.php -index fb429a2..2978ba2 100644 +index bfdc4a0..a307bea 100644 --- a/examples/recaptcha-v2-checkbox-explicit.php +++ b/examples/recaptcha-v2-checkbox-explicit.php @@ -35,7 +35,7 @@ require __DIR__ . '/appengine-https.php'; @@ -39,11 +39,11 @@ // Register API keys at https://www.google.com/recaptcha/admin $siteKey = ''; diff --git a/examples/recaptcha-v2-checkbox.php b/examples/recaptcha-v2-checkbox.php -index 9395d59..299eaf5 100644 +index 7eb5e4b..91e36b7 100644 --- a/examples/recaptcha-v2-checkbox.php +++ b/examples/recaptcha-v2-checkbox.php @@ -35,7 +35,7 @@ require __DIR__ . '/appengine-https.php'; - // Initiate the autoloader. The file should be generated by Composer. + // Initiate the autoloader. The file should be generated by Composer. // You will provide your own autoloader or require the files directly if you did // not install via Composer. -require_once __DIR__ . '/../vendor/autoload.php'; @@ -52,11 +52,11 @@ // Register API keys at https://www.google.com/recaptcha/admin $siteKey = ''; diff --git a/examples/recaptcha-v2-invisible.php b/examples/recaptcha-v2-invisible.php -index c3b9397..3d64013 100644 +index bed5d4f..94c19e2 100644 --- a/examples/recaptcha-v2-invisible.php +++ b/examples/recaptcha-v2-invisible.php @@ -35,7 +35,7 @@ require __DIR__ . '/appengine-https.php'; - // Initiate the autoloader. The file should be generated by Composer. + // Initiate the autoloader. The file should be generated by Composer. // You will provide your own autoloader or require the files directly if you did // not install via Composer. -require_once __DIR__ . '/../vendor/autoload.php'; @@ -65,7 +65,7 @@ // Register API keys at https://www.google.com/recaptcha/admin $siteKey = ''; diff --git a/examples/recaptcha-v3-request-scores.php b/examples/recaptcha-v3-request-scores.php -index d9430bb..0b45cc7 100644 +index 766c373..ae0bba4 100644 --- a/examples/recaptcha-v3-request-scores.php +++ b/examples/recaptcha-v3-request-scores.php @@ -35,7 +35,7 @@ require __DIR__ . '/appengine-https.php'; diff -Nru google-recaptcha-1.2.4/debian/patches/series google-recaptcha-1.3.0/debian/patches/series --- google-recaptcha-1.2.4/debian/patches/series 2021-01-14 20:50:02.000000000 +0000 +++ google-recaptcha-1.3.0/debian/patches/series 2024-04-19 23:00:24.000000000 +0000 @@ -1,3 +1 @@ -Adapt-to-recent-version-of-PHPUnit-9.patch Updates-examples-autoload-require-path.patch -Set-php-type-hints-for-phpunit.patch diff -Nru google-recaptcha-1.2.4/debian/watch google-recaptcha-1.3.0/debian/watch --- google-recaptcha-1.2.4/debian/watch 2021-01-14 16:35:42.000000000 +0000 +++ google-recaptcha-1.3.0/debian/watch 2024-04-19 23:00:24.000000000 +0000 @@ -1,8 +1,4 @@ -# Compulsory line, this is a version 4 file version=4 - -# GitHub hosted projects -opts="filenamemangle=s%(?:.*?)?v?(\d[\d.]*)\.tar\.gz%-$1.tar.gz%" \ - https://github.com/google/recaptcha/tags \ - (?:.*?/)?v?(\d[\d.]*)\.tar\.gz debian uupdate - +options="mode=git, gitmode=full, gitexport=all, pgpmode=none" \ + https://github.com/google/recaptcha/ \ + refs/tags/([\d\.]+) diff -Nru google-recaptcha-1.2.4/examples/recaptcha-content-security-policy.php google-recaptcha-1.3.0/examples/recaptcha-content-security-policy.php --- google-recaptcha-1.2.4/examples/recaptcha-content-security-policy.php 2020-03-31 17:50:54.000000000 +0000 +++ google-recaptcha-1.3.0/examples/recaptcha-content-security-policy.php 2023-02-18 17:41:46.000000000 +0000 @@ -103,7 +103,7 @@
+ ?>

Add your keys

If you do not have keys already then visit https://www.google.com/recaptcha/admin to generate them. Edit this file and set the respective keys in $siteKey and $secret. Reload the page after this.

+ ?>

Add your keys

If you do not have keys already then visit https://www.google.com/recaptcha/admin to generate them. Edit this file and set the respective keys in the config.php file or directly to $siteKey and $secret. Reload the page after this.

+ ?>

Add your keys

If you do not have keys already then visit https://www.google.com/recaptcha/admin to generate them. Edit this file and set the respective keys in the config.php file or directly to $siteKey and $secret. Reload the page after this.

+ ?>

Add your keys

If you do not have keys already then visit https://www.google.com/recaptcha/admin to generate them. Edit this file and set the respective keys in $siteKey and $secret. Reload the page after this.

+ ?>

Add your keys

If you do not have keys already then visit https://www.google.com/recaptcha/admin to generate them. Edit this file and set the respective keys in $siteKey and $secret. Reload the page after this.

- - - - tests/ReCaptcha/ - - - - - src/ReCaptcha/ - - - - - + + + + src/ReCaptcha/ + + + + + + + + tests/ReCaptcha/ + + + diff -Nru google-recaptcha-1.2.4/src/ReCaptcha/ReCaptcha.php google-recaptcha-1.3.0/src/ReCaptcha/ReCaptcha.php --- google-recaptcha-1.2.4/src/ReCaptcha/ReCaptcha.php 2020-03-31 17:50:54.000000000 +0000 +++ google-recaptcha-1.3.0/src/ReCaptcha/ReCaptcha.php 2023-02-18 17:41:46.000000000 +0000 @@ -43,73 +43,73 @@ * Version of this client library. * @const string */ - const VERSION = 'php_1.2.4'; + public const VERSION = 'php_1.3.0'; /** * URL for reCAPTCHA siteverify API * @const string */ - const SITE_VERIFY_URL = 'https://www.google.com/recaptcha/api/siteverify'; + public const SITE_VERIFY_URL = 'https://www.google.com/recaptcha/api/siteverify'; /** * Invalid JSON received * @const string */ - const E_INVALID_JSON = 'invalid-json'; + public const E_INVALID_JSON = 'invalid-json'; /** * Could not connect to service * @const string */ - const E_CONNECTION_FAILED = 'connection-failed'; + public const E_CONNECTION_FAILED = 'connection-failed'; /** * Did not receive a 200 from the service * @const string */ - const E_BAD_RESPONSE = 'bad-response'; + public const E_BAD_RESPONSE = 'bad-response'; /** * Not a success, but no error codes received! * @const string */ - const E_UNKNOWN_ERROR = 'unknown-error'; + public const E_UNKNOWN_ERROR = 'unknown-error'; /** * ReCAPTCHA response not provided * @const string */ - const E_MISSING_INPUT_RESPONSE = 'missing-input-response'; + public const E_MISSING_INPUT_RESPONSE = 'missing-input-response'; /** * Expected hostname did not match * @const string */ - const E_HOSTNAME_MISMATCH = 'hostname-mismatch'; + public const E_HOSTNAME_MISMATCH = 'hostname-mismatch'; /** * Expected APK package name did not match * @const string */ - const E_APK_PACKAGE_NAME_MISMATCH = 'apk_package_name-mismatch'; + public const E_APK_PACKAGE_NAME_MISMATCH = 'apk_package_name-mismatch'; /** * Expected action did not match * @const string */ - const E_ACTION_MISMATCH = 'action-mismatch'; + public const E_ACTION_MISMATCH = 'action-mismatch'; /** * Score threshold not met * @const string */ - const E_SCORE_THRESHOLD_NOT_MET = 'score-threshold-not-met'; + public const E_SCORE_THRESHOLD_NOT_MET = 'score-threshold-not-met'; /** * Challenge timeout * @const string */ - const E_CHALLENGE_TIMEOUT = 'challenge-timeout'; + public const E_CHALLENGE_TIMEOUT = 'challenge-timeout'; /** * Shared secret for the site. @@ -123,6 +123,12 @@ */ private $requestMethod; + private $hostname; + private $apkPackageName; + private $action; + private $threshold; + private $timeoutSeconds; + /** * Create a configured instance to use the reCAPTCHA service. * diff -Nru google-recaptcha-1.2.4/src/ReCaptcha/RequestMethod/Curl.php google-recaptcha-1.3.0/src/ReCaptcha/RequestMethod/Curl.php --- google-recaptcha-1.2.4/src/ReCaptcha/RequestMethod/Curl.php 2020-03-31 17:50:54.000000000 +0000 +++ google-recaptcha-1.3.0/src/ReCaptcha/RequestMethod/Curl.php 2023-02-18 17:41:46.000000000 +0000 @@ -39,7 +39,6 @@ */ class Curl { - /** * @see http://php.net/curl_init * @param string $url diff -Nru google-recaptcha-1.2.4/src/ReCaptcha/RequestMethod/SocketPost.php google-recaptcha-1.3.0/src/ReCaptcha/RequestMethod/SocketPost.php --- google-recaptcha-1.2.4/src/ReCaptcha/RequestMethod/SocketPost.php 2020-03-31 17:50:54.000000000 +0000 +++ google-recaptcha-1.3.0/src/ReCaptcha/RequestMethod/SocketPost.php 2023-02-18 17:41:46.000000000 +0000 @@ -51,6 +51,8 @@ */ private $socket; + private $siteVerifyUrl; + /** * Only needed if you want to override the defaults * diff -Nru google-recaptcha-1.2.4/src/ReCaptcha/RequestMethod.php google-recaptcha-1.3.0/src/ReCaptcha/RequestMethod.php --- google-recaptcha-1.2.4/src/ReCaptcha/RequestMethod.php 2020-03-31 17:50:54.000000000 +0000 +++ google-recaptcha-1.3.0/src/ReCaptcha/RequestMethod.php 2023-02-18 17:41:46.000000000 +0000 @@ -39,7 +39,6 @@ */ interface RequestMethod { - /** * Submit the request with the specified parameters. * diff -Nru google-recaptcha-1.2.4/src/ReCaptcha/Response.php google-recaptcha-1.3.0/src/ReCaptcha/Response.php --- google-recaptcha-1.2.4/src/ReCaptcha/Response.php 2020-03-31 17:50:54.000000000 +0000 +++ google-recaptcha-1.3.0/src/ReCaptcha/Response.php 2023-02-18 17:41:46.000000000 +0000 @@ -95,11 +95,11 @@ return new Response(false, array(ReCaptcha::E_INVALID_JSON)); } - $hostname = isset($responseData['hostname']) ? $responseData['hostname'] : null; - $challengeTs = isset($responseData['challenge_ts']) ? $responseData['challenge_ts'] : null; - $apkPackageName = isset($responseData['apk_package_name']) ? $responseData['apk_package_name'] : null; + $hostname = isset($responseData['hostname']) ? $responseData['hostname'] : ''; + $challengeTs = isset($responseData['challenge_ts']) ? $responseData['challenge_ts'] : ''; + $apkPackageName = isset($responseData['apk_package_name']) ? $responseData['apk_package_name'] : ''; $score = isset($responseData['score']) ? floatval($responseData['score']) : null; - $action = isset($responseData['action']) ? $responseData['action'] : null; + $action = isset($responseData['action']) ? $responseData['action'] : ''; if (isset($responseData['success']) && $responseData['success'] == true) { return new Response(true, array(), $hostname, $challengeTs, $apkPackageName, $score, $action); @@ -123,7 +123,7 @@ * @param string $action * @param array $errorCodes */ - public function __construct($success, array $errorCodes = array(), $hostname = null, $challengeTs = null, $apkPackageName = null, $score = null, $action = null) + public function __construct($success, array $errorCodes = array(), $hostname = '', $challengeTs = '', $apkPackageName = '', $score = null, $action = '') { $this->success = $success; $this->hostname = $hostname; diff -Nru google-recaptcha-1.2.4/tests/ReCaptcha/ReCaptchaTest.php google-recaptcha-1.3.0/tests/ReCaptcha/ReCaptchaTest.php --- google-recaptcha-1.2.4/tests/ReCaptcha/ReCaptchaTest.php 2020-03-31 17:50:54.000000000 +0000 +++ google-recaptcha-1.3.0/tests/ReCaptcha/ReCaptchaTest.php 2023-02-18 17:41:46.000000000 +0000 @@ -38,17 +38,16 @@ class ReCaptchaTest extends TestCase { - /** - * @expectedException \RuntimeException * @dataProvider invalidSecretProvider */ public function testExceptionThrownOnInvalidSecret($invalid) { + $this->expectException(\RuntimeException::class); $rc = new ReCaptcha($invalid); } - public function invalidSecretProvider() + public static function invalidSecretProvider() { return array( array(''), @@ -71,7 +70,6 @@ { $method = $this->getMockBuilder(\ReCaptcha\RequestMethod::class) ->disableOriginalConstructor() - ->setMethods(array('submit')) ->getMock(); $method->expects($this->any()) ->method('submit') diff -Nru google-recaptcha-1.2.4/tests/ReCaptcha/RequestMethod/CurlPostTest.php google-recaptcha-1.3.0/tests/ReCaptcha/RequestMethod/CurlPostTest.php --- google-recaptcha-1.2.4/tests/ReCaptcha/RequestMethod/CurlPostTest.php 2020-03-31 17:50:54.000000000 +0000 +++ google-recaptcha-1.3.0/tests/ReCaptcha/RequestMethod/CurlPostTest.php 2023-02-18 17:41:46.000000000 +0000 @@ -34,13 +34,13 @@ namespace ReCaptcha\RequestMethod; -use \ReCaptcha\ReCaptcha; -use \ReCaptcha\RequestParameters; +use ReCaptcha\ReCaptcha; +use ReCaptcha\RequestParameters; use PHPUnit\Framework\TestCase; class CurlPostTest extends TestCase { - protected function setUp() + protected function setUp(): void { if (!extension_loaded('curl')) { $this->markTestSkipped( @@ -53,11 +53,10 @@ { $curl = $this->getMockBuilder(\ReCaptcha\RequestMethod\Curl::class) ->disableOriginalConstructor() - ->setMethods(array('init', 'setoptArray', 'exec', 'close')) ->getMock(); $curl->expects($this->once()) ->method('init') - ->willReturn(new \stdClass); + ->willReturn(new \stdClass()); $curl->expects($this->once()) ->method('setoptArray') ->willReturn(true); @@ -78,12 +77,11 @@ $curl = $this->getMockBuilder(\ReCaptcha\RequestMethod\Curl::class) ->disableOriginalConstructor() - ->setMethods(array('init', 'setoptArray', 'exec', 'close')) ->getMock(); $curl->expects($this->once()) ->method('init') ->with($url) - ->willReturn(new \stdClass); + ->willReturn(new \stdClass()); $curl->expects($this->once()) ->method('setoptArray') ->willReturn(true); @@ -102,11 +100,10 @@ { $curl = $this->getMockBuilder(\ReCaptcha\RequestMethod\Curl::class) ->disableOriginalConstructor() - ->setMethods(array('init', 'setoptArray', 'exec', 'close')) ->getMock(); $curl->expects($this->once()) ->method('init') - ->willReturn(new \stdClass); + ->willReturn(new \stdClass()); $curl->expects($this->once()) ->method('setoptArray') ->willReturn(true); diff -Nru google-recaptcha-1.2.4/tests/ReCaptcha/RequestMethod/PostTest.php google-recaptcha-1.3.0/tests/ReCaptcha/RequestMethod/PostTest.php --- google-recaptcha-1.2.4/tests/ReCaptcha/RequestMethod/PostTest.php 2020-03-31 17:50:54.000000000 +0000 +++ google-recaptcha-1.3.0/tests/ReCaptcha/RequestMethod/PostTest.php 2023-02-18 17:41:46.000000000 +0000 @@ -34,7 +34,7 @@ namespace ReCaptcha\RequestMethod; -use \ReCaptcha\ReCaptcha; +use ReCaptcha\ReCaptcha; use ReCaptcha\RequestParameters; use PHPUnit\Framework\TestCase; @@ -44,12 +44,12 @@ protected $parameters = null; protected $runcount = 0; - public function setUp() + public function setUp(): void { $this->parameters = new RequestParameters('secret', 'response', 'remoteip', 'version'); } - public function tearDown() + public function tearDown(): void { self::$assert = null; } @@ -111,12 +111,7 @@ $this->assertEquals($this->parameters->toQueryString(), $options['http']['content']); $this->assertArrayHasKey('header', $options['http']); - $headers = array( - 'Content-type: application/x-www-form-urlencoded', - ); - foreach ($headers as $header) { - $this->assertContains($header, $options['http']['header']); - } + $this->assertStringContainsStringIgnoringCase('Content-type: application/x-www-form-urlencoded', $options['http']['header']); } public function sslContextOptionsCallback(array $args) diff -Nru google-recaptcha-1.2.4/tests/ReCaptcha/RequestMethod/SocketPostTest.php google-recaptcha-1.3.0/tests/ReCaptcha/RequestMethod/SocketPostTest.php --- google-recaptcha-1.2.4/tests/ReCaptcha/RequestMethod/SocketPostTest.php 2020-03-31 17:50:54.000000000 +0000 +++ google-recaptcha-1.3.0/tests/ReCaptcha/RequestMethod/SocketPostTest.php 2023-02-18 17:41:46.000000000 +0000 @@ -44,7 +44,6 @@ { $socket = $this->getMockBuilder(\ReCaptcha\RequestMethod\Socket::class) ->disableOriginalConstructor() - ->setMethods(array('fsockopen', 'fwrite', 'fgets', 'feof', 'fclose')) ->getMock(); $socket->expects($this->once()) ->method('fsockopen') @@ -70,7 +69,6 @@ { $socket = $this->getMockBuilder(\ReCaptcha\RequestMethod\Socket::class) ->disableOriginalConstructor() - ->setMethods(array('fsockopen', 'fwrite', 'fgets', 'feof', 'fclose')) ->getMock(); $socket->expects($this->once()) ->method('fsockopen') @@ -98,7 +96,6 @@ { $socket = $this->getMockBuilder(\ReCaptcha\RequestMethod\Socket::class) ->disableOriginalConstructor() - ->setMethods(array('fsockopen', 'fwrite', 'fgets', 'feof', 'fclose')) ->getMock(); $socket->expects($this->once()) ->method('fsockopen') @@ -124,7 +121,6 @@ { $socket = $this->getMockBuilder(\ReCaptcha\RequestMethod\Socket::class) ->disableOriginalConstructor() - ->setMethods(array('fsockopen')) ->getMock(); $socket->expects($this->once()) ->method('fsockopen') diff -Nru google-recaptcha-1.2.4/tests/ReCaptcha/RequestParametersTest.php google-recaptcha-1.3.0/tests/ReCaptcha/RequestParametersTest.php --- google-recaptcha-1.2.4/tests/ReCaptcha/RequestParametersTest.php 2020-03-31 17:50:54.000000000 +0000 +++ google-recaptcha-1.3.0/tests/ReCaptcha/RequestParametersTest.php 2023-02-18 17:41:46.000000000 +0000 @@ -38,7 +38,7 @@ class RequestParametersTest extends Testcase { - public function provideValidData() + public static function provideValidData() { return array( array('SECRET', 'RESPONSE', 'REMOTEIP', 'VERSION', diff -Nru google-recaptcha-1.2.4/tests/ReCaptcha/ResponseTest.php google-recaptcha-1.3.0/tests/ReCaptcha/ResponseTest.php --- google-recaptcha-1.2.4/tests/ReCaptcha/ResponseTest.php 2020-03-31 17:50:54.000000000 +0000 +++ google-recaptcha-1.3.0/tests/ReCaptcha/ResponseTest.php 2023-02-18 17:41:46.000000000 +0000 @@ -38,7 +38,6 @@ class ResponseTest extends TestCase { - /** * @dataProvider provideJson */ @@ -54,7 +53,7 @@ $this->assertEquals($action, $response->getAction()); } - public function provideJson() + public static function provideJson() { return array( array(