new: pkg: add test cases to back-end w/ real database connection in it #10
This commit is contained in:
33
src/Story/AppStory.php
Normal file
33
src/Story/AppStory.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* This file is part of the SplendidBear Websites' projects.
|
||||
*
|
||||
* Copyright (c) 2026 @ www.splendidbear.org
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace App\Story;
|
||||
|
||||
use Zenstruck\Foundry\Attribute\AsFixture;
|
||||
use Zenstruck\Foundry\Story;
|
||||
|
||||
/**
|
||||
* Class AppStory
|
||||
*
|
||||
* @package App\Story
|
||||
* @author Lang <https://www.splendidbear.org>
|
||||
* @category Class
|
||||
* @license https://www.gnu.org/licenses/lgpl-3.0.en.html GNU Lesser General Public License
|
||||
* @link www.splendidbear.org
|
||||
* @since 2026. 04. 21.
|
||||
*/
|
||||
#[AsFixture(name: 'main')]
|
||||
final class AppStory extends Story
|
||||
{
|
||||
public function build(): void
|
||||
{
|
||||
// SomeFactory::createOne();
|
||||
}
|
||||
}
|
||||
@@ -26,12 +26,13 @@ use Symfony\Component\Validator\Exception\UnexpectedTypeException;
|
||||
* @link www.splendidbear.org
|
||||
* @since 2026. 04. 12.
|
||||
*/
|
||||
class RecaptchaValidator extends ConstraintValidator
|
||||
final class RecaptchaValidator extends ConstraintValidator
|
||||
{
|
||||
public function __construct(
|
||||
private readonly RecaptchaService $recaptcha,
|
||||
private readonly RequestStack $requestStack,
|
||||
) {}
|
||||
private readonly RequestStack $requestStack,
|
||||
) {
|
||||
}
|
||||
|
||||
public function validate(mixed $value, Constraint $constraint): void
|
||||
{
|
||||
@@ -39,10 +40,10 @@ class RecaptchaValidator extends ConstraintValidator
|
||||
throw new UnexpectedTypeException($constraint, Recaptcha::class);
|
||||
}
|
||||
|
||||
$request = $this->requestStack->getCurrentRequest();
|
||||
$remoteIp = $request !== null ? ((string) $request->getClientIp()) : '';
|
||||
$request = $this->requestStack->getCurrentRequest();
|
||||
$remoteIp = $request !== null ? ((string)$request->getClientIp()) : '';
|
||||
|
||||
if ($this->recaptcha->verify((string) $value, $remoteIp)) {
|
||||
if ($this->recaptcha->verify((string)$value, $remoteIp)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user