Skip to content

Commit 47ed5d9

Browse files
author
ogorkun
committed
MC-37783: Introduce ReCaptcha coverage for checkout
1 parent 8b29b90 commit 47ed5d9

File tree

12 files changed

+18
-13
lines changed

12 files changed

+18
-13
lines changed

ReCaptchaCheckout/Block/LayoutProcessor/Checkout/Onepage.php

+1-5
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,7 @@ public function __construct(
4040
}
4141

4242
/**
43-
* {@inheritdoc}
44-
*
45-
* @param array $jsLayout
46-
* @return array
47-
* @throws InputException
43+
* @inheritDoc
4844
*/
4945
public function process($jsLayout)
5046
{

ReCaptchaCheckout/Model/WebapiConfigProvider.php

+2
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public function __construct(IsCaptchaEnabledInterface $isEnabled, ValidationConf
4545
*/
4646
public function getConfigFor(EndpointInterface $endpoint): ?ValidationConfigInterface
4747
{
48+
//phpcs:disable Magento2.PHP.LiteralNamespaces
4849
if ($endpoint->getServiceMethod() === 'savePaymentInformationAndPlaceOrder'
4950
|| $endpoint->getServiceClass() === 'Magento\QuoteGraphQl\Model\Resolver\SetPaymentAndPlaceOrder'
5051
|| $endpoint->getServiceClass() === 'Magento\QuoteGraphQl\Model\Resolver\PlaceOrder'
@@ -53,6 +54,7 @@ public function getConfigFor(EndpointInterface $endpoint): ?ValidationConfigInte
5354
return $this->configResolver->get(self::CAPTCHA_ID);
5455
}
5556
}
57+
//phpcs:enable Magento2.PHP.LiteralNamespaces
5658

5759
return null;
5860
}

ReCaptchaWebapiApi/Model/CompositeWebapiValidationConfigProvider.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,4 @@ public function getConfigFor(EndpointInterface $endpoint): ?ValidationConfigInte
4646

4747
return null;
4848
}
49-
}
49+
}

ReCaptchaWebapiGraphQl/Plugin/GraphQlValidator.php

+2
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ public function __construct(
6666
* @param ConfigElementInterface $configElement
6767
* @throws GraphQlInputException
6868
* @return void
69+
*
70+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
6971
*/
7072
public function beforeFormat(
7173
Fields $subject,

ReCaptchaWebapiGraphQl/Plugin/ValidationOverrider.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ public function __construct(UserContextInterface $userContext)
3838
* @param string $value
3939
* @param ValidationConfigInterface $config
4040
* @return ValidationResult
41+
*
42+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
4143
*/
4244
public function aroundIsValid(
4345
ValidatorInterface $subject,
@@ -51,4 +53,4 @@ public function aroundIsValid(
5153

5254
return $proceed($value, $config);
5355
}
54-
}
56+
}

ReCaptchaWebapiGraphQl/Test/Unit/Plugin/GraphQlValidatorTest.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ public function testPlugin(bool $isMutation, bool $configFound, bool $isValid, b
9696
->willReturn($this->createMock(Endpoint::class));
9797
//Emulating config found
9898
$this->configProviderMock->method('getConfigFor')
99-
->willReturnOnConsecutiveCalls(null,
99+
->willReturnOnConsecutiveCalls(
100+
null,
100101
$configFound ? $this->getMockForAbstractClass(ValidationConfigInterface::class) : null
101102
);
102103
//Emulating validation result

ReCaptchaWebapiGraphQl/Test/Unit/Plugin/ValidationOverriderTest.php

-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ public function testForUsers(int $type, ?int $id, bool $executed): void
6262
->willReturn($id);
6363

6464
$this->assertEquals($executed, $this->runModel());
65-
6665
}
6766

6867
/**

ReCaptchaWebapiGraphQl/composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "magento/module-re-captcha-webapi-graphql",
2+
"name": "magento/module-re-captcha-webapi-graph-ql",
33
"description": "Google reCAPTCHA integration for Magento2",
44
"require": {
55
"php": "~7.3.0||~7.4.0",

ReCaptchaWebapiRest/Plugin/SoapValidationPlugin.php

+2
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ public function __construct(
7373
* @param Handler $subject
7474
* @param string $operation
7575
* @throws WebapiException
76+
*
77+
* @phpcs:disable PSR1.Methods.CamelCapsMethodName
7678
*/
7779
public function before__call(Handler $subject, string $operation): void
7880
{

ReCaptchaWebapiRest/Plugin/ValidationOverrider.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ public function __construct(UserContextInterface $userContext)
3838
* @param string $value
3939
* @param ValidationConfigInterface $config
4040
* @return ValidationResult
41+
*
42+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
4143
*/
4244
public function aroundIsValid(
4345
ValidatorInterface $subject,
@@ -51,4 +53,4 @@ public function aroundIsValid(
5153

5254
return $proceed($value, $config);
5355
}
54-
}
56+
}

ReCaptchaWebapiRest/Test/Unit/Plugin/ValidationOverriderTest.php

-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ public function testForUsers(int $type, ?int $id, bool $executed): void
6262
->willReturn($id);
6363

6464
$this->assertEquals($executed, $this->runModel());
65-
6665
}
6766

6867
/**

_metapackage/composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"magento/module-re-captcha-version-3-invisible": "*",
2323
"magento/module-re-captcha-webapi-api": "*",
2424
"magento/module-re-captcha-webapi-rest": "*",
25-
"magento/module-re-captcha-webapi-graphql": "*",
25+
"magento/module-re-captcha-webapi-graph-ql": "*",
2626
"magento/module-re-captcha-webapi-ui": "*",
2727
"magento/module-securitytxt": "*",
2828
"magento/module-two-factor-auth": "*",

0 commit comments

Comments
 (0)