diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1985a58..7c4236d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,34 +14,51 @@ jobs: strategy: fail-fast: true matrix: - php: [7.1, 7.2, 7.3, 7.4, 8.0, 8.1, 8.2] - symfony: [2.8, 3.4, 4.4, 5.2, 6.0, 7.0] + php: [7.1, 7.2, 7.3, 7.4, 8.0, 8.1, 8.2, 8.3, 8.4, 8.5] + symfony: [2.8, 3.4, 4.4, 5.4, 6.4, 7.4, 8.0] exclude: # Symfony 5 requires PHP >= 7.2 - php: 7.1 - symfony: 5.2 + symfony: 5.4 # Symfony 6 requires PHP >= 8.0 - php: 7.1 - symfony: 6.0 + symfony: 6.4 - php: 7.2 - symfony: 6.0 + symfony: 6.4 - php: 7.3 - symfony: 6.0 + symfony: 6.4 - php: 7.4 - symfony: 6.0 + symfony: 6.4 # Symfony 7 requires PHP >= 8.2 - php: 7.1 - symfony: 7.0 + symfony: 7.4 - php: 7.2 - symfony: 7.0 + symfony: 7.4 - php: 7.3 - symfony: 7.0 + symfony: 7.4 - php: 7.4 - symfony: 7.0 + symfony: 7.4 - php: 8.0 - symfony: 7.0 + symfony: 7.4 - php: 8.1 - symfony: 7.0 + symfony: 7.4 + # Symfony 8 requires PHP >= 8.4 + - php: 7.1 + symfony: 8.0 + - php: 7.2 + symfony: 8.0 + - php: 7.3 + symfony: 8.0 + - php: 7.4 + symfony: 8.0 + - php: 8.0 + symfony: 8.0 + - php: 8.1 + symfony: 8.0 + - php: 8.2 + symfony: 8.0 + - php: 8.3 + symfony: 8.0 steps: - name: Checkout uses: actions/checkout@v4 diff --git a/composer.json b/composer.json index e946dc4..a0f0882 100644 --- a/composer.json +++ b/composer.json @@ -17,11 +17,11 @@ "require": { "php": "^7.1 || ^8.0", "google/recaptcha": "^1.1", - "symfony/form": "^2.8 || ^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0", - "symfony/framework-bundle": "^2.8 || ^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0", - "symfony/security-bundle": "^2.8 || ^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0", - "symfony/validator": "^2.8 || ^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0", - "symfony/yaml": "^2.8 || ^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0", + "symfony/form": "^2.8 || ^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0", + "symfony/framework-bundle": "^2.8 || ^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0", + "symfony/security-bundle": "^2.8 || ^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0", + "symfony/validator": "^2.8 || ^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0", + "symfony/yaml": "^2.8 || ^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0", "twig/twig": "^1.40 || ^2.9 || ^3.0" }, "require-dev": { diff --git a/src/Validator/Constraints/IsTrueValidator.php b/src/Validator/Constraints/IsTrueValidator.php index 963329a..36e7cb0 100755 --- a/src/Validator/Constraints/IsTrueValidator.php +++ b/src/Validator/Constraints/IsTrueValidator.php @@ -102,7 +102,7 @@ public function validate($value, Constraint $constraint): void $remoteip = $request->getClientIp(); // define variable for recaptcha check answer - $answer = $request->get('g-recaptcha-response'); + $answer = $request->request->get('g-recaptcha-response'); // Verify user response with Google $response = $this->recaptcha->verify($answer, $remoteip); diff --git a/tests/Validator/Constraints/IsTrueValidatorTest.php b/tests/Validator/Constraints/IsTrueValidatorTest.php index 38fd86e..d69dd04 100644 --- a/tests/Validator/Constraints/IsTrueValidatorTest.php +++ b/tests/Validator/Constraints/IsTrueValidatorTest.php @@ -7,6 +7,7 @@ use PHPUnit\Framework\TestCase; use ReCaptcha\ReCaptcha; use ReCaptcha\Response; +use Symfony\Component\HttpFoundation\InputBag; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface; @@ -89,10 +90,7 @@ public function testResponseNotSuccess(): void $request->expects(self::once()) ->method('getClientIp') ->willReturn($clientIp); - $request->expects(self::once()) - ->method('get') - ->with('g-recaptcha-response') - ->willReturn($recaptchaAnswer); + $request->request = new InputBag(['g-recaptcha-response' => $recaptchaAnswer]); if (\is_callable([$requestStack, 'getMainRequest'])) { $requestStack->expects(self::once()) @@ -145,10 +143,7 @@ public function testInvalidHostWithVerifyHost(): void $request->expects(self::once()) ->method('getClientIp') ->willReturn($clientIp); - $request->expects(self::once()) - ->method('get') - ->with('g-recaptcha-response') - ->willReturn($recaptchaAnswer); + $request->request = new InputBag(['g-recaptcha-response' => $recaptchaAnswer]); $request->expects(self::once()) ->method('getHost') ->willReturn('host1'); @@ -207,10 +202,7 @@ public function testInvalidHostWithoutVerifyHost(): void $request->expects(self::once()) ->method('getClientIp') ->willReturn($clientIp); - $request->expects(self::once()) - ->method('get') - ->with('g-recaptcha-response') - ->willReturn($recaptchaAnswer); + $request->request = new InputBag(['g-recaptcha-response' => $recaptchaAnswer]); $request->expects(self::never()) ->method('getHost'); @@ -269,10 +261,7 @@ public function testValidWithVerifyHost(): void $request->expects(self::once()) ->method('getClientIp') ->willReturn($clientIp); - $request->expects(self::once()) - ->method('get') - ->with('g-recaptcha-response') - ->willReturn($recaptchaAnswer); + $request->request = new InputBag(['g-recaptcha-response' => $recaptchaAnswer]); $request->expects(self::once()) ->method('getHost') ->willReturn($host);