Skip to content

Commit 3457837

Browse files
committed
Fix tests for Validate Captchas
1 parent 06cc5ae commit 3457837

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/Phpbb/TranslationValidator/Validator/FileValidator.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -667,10 +667,15 @@ public function validateJsonFile($originFile)
667667
* Check that the reCaptcha and Turnstile key provided is allowed
668668
* @param $originFile
669669
*/
670-
public function validateCaptchaValues($originFile)
670+
public function validateCaptchaValues($originFile, $optParams = 'incorrect')
671671
{
672672
$jsonContent = $this->openComposerJson($originFile);
673673

674+
if (!$optParams == '')
675+
{
676+
$jsonContent['extra']['recaptcha-lang'] = $optParams;
677+
//$jsonContent['extra']['turnstile-lang'] = $optParams;
678+
}
674679
// The key 'RECAPTCHA_LANG' must match the list provided by Google, or be left empty
675680
// Check for valid recaptcha-lang: en-GB
676681
if (!in_array($jsonContent['extra']['recaptcha-lang'], $this->reCaptchaLanguages))

tests/FileValidator/ValidateLangTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ public function testValidateLangFile($file, $expected)
4141
/**
4242
* Test the reCaptcha checks
4343
*/
44-
public function testValidateLangReCaptcha()
44+
public function testValidateLangCaptchas()
4545
{
4646
// Failure - as we supply a key that isn't valid
47-
$reCaptchaLanguage = ['RECAPTCHA_LANG' => 'incorrect'];
47+
$reCaptchaLanguage = 'incorrect';
4848
$this->validator->validateCaptchaValues('', $reCaptchaLanguage);
4949

5050
$output = $this->output->getMessages();
@@ -54,7 +54,7 @@ public function testValidateLangReCaptcha()
5454
$this->assertEquals($output[0], $expected);
5555

5656
// Pass - as 'en' is valid
57-
$reCaptchaLanguage['RECAPTCHA_LANG'] = 'en';
57+
$reCaptchaLanguage = 'en';
5858
$this->validator->validateCaptchaValues('', $reCaptchaLanguage);
5959

6060
$this->assertEquals($this->output->getMessageCount(Output::ERROR), 1); // Shouldn't change in size as no error added

0 commit comments

Comments
 (0)