You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I followed your readme and successfully integrate google recaptcha3 to my site. It works fine. But when testing it throws error.
Errror:
App\Tests\Form\ContactTypeTest::testSubmitValidData
ArgumentCountError: Too few arguments to functionKarser\Recaptcha3Bundle\Form\Recaptcha3Type::__construct(), 0 passed in /home/sudhakar/SudhakarK/NB/2022/FZMFW/vendor/symfony/form/FormRegistry.php on line 81 and exactly 3 expected
/home/sudhakar/SudhakarK/NB/2022/FZMFW/vendor/karser/karser-recaptcha3-bundle/Form/Recaptcha3Type.php:22
/home/sudhakar/SudhakarK/NB/2022/FZMFW/vendor/symfony/form/FormRegistry.php:81
/home/sudhakar/SudhakarK/NB/2022/FZMFW/vendor/symfony/form/FormFactory.php:67
/home/sudhakar/SudhakarK/NB/2022/FZMFW/vendor/symfony/form/FormBuilder.php:91
/home/sudhakar/SudhakarK/NB/2022/FZMFW/vendor/symfony/form/FormBuilder.php:238
/home/sudhakar/SudhakarK/NB/2022/FZMFW/vendor/symfony/form/FormBuilder.php:189
/home/sudhakar/SudhakarK/NB/2022/FZMFW/vendor/symfony/form/FormFactory.php:31
/home/sudhakar/SudhakarK/NB/2022/FZMFW/tests/Form/ContactTypeTest.php:33
Here # TEST PASSES WHEN I REMOVE 'captcha' (I mentioned in above code)
ContactTypeTest:
<?php/* * Copyright (C) 2009 - 2022 * Author: Sudhakar Krishnan <featuriz@gmail.com> * License: http://www.featuriz.in/licenses/LICENSE-2.0 * Created: Mon, 14 Nov 2022 13:30:28 IST */namespaceApp\Tests\Form;
useApp\Form\ContactType;
useApp\Entity\Contact;
useSymfony\Component\Form\Test\TypeTestCase;
/** * Description of ContactTypeTest * * @author Sudhakar Krishnan <featuriz@gmail.com> */class ContactTypeTest extends TypeTestCase {
publicfunctiontestSubmitValidData() {
$formData = [
'name' => 'My Name',
'email' => 'info',
'phone' => '123',
'message' => 'hi',
];
$model = newContact();
// $model will retrieve data from the form submission; pass it as the second argument$form = $this->factory->create(ContactType::class, $model);
$expected = newContact();
// ...populate $expected properties with the data stored in $formData$expected->setName("My Name")->setEmail("info")->setPhone("123")->setMessage("hi");
// submit the data to the form directly$form->submit($formData);
// This check ensures there are no transformation failures$this->assertTrue($form->isSynchronized());
// check that $model was modified as expected when the form was submitted$this->assertEquals($expected, $model);
$this->assertEquals($expected, $form->getData());
$view = $form->createView();
$children = $view->children;
foreach (array_keys($formData) as$key) {
$this->assertArrayHasKey($key, $children);
}
}
publicfunctiontestCustomFormView() {
$formData = newContact();
// ... prepare the data as you need$formData->setName("My Name")->setEmail("info")->setPhone("123")->setMessage("hi");
// The initial data may be used to compute custom view variables$view = $this->factory->create(ContactType::class, $formData)
->createView();
$this->assertArrayHasKey('id', $view->vars);
$this->assertArrayHasKey('name', $view->vars);
$this->assertArrayHasKey('method', $view->vars);
$this->assertSame('contact', $view->vars['id']);
$this->assertSame('contact', $view->vars['name']);
$this->assertSame('POST', $view->vars['method']);
}
}
I don't know what I'm doing wrong here. My config:
I followed your readme and successfully integrate google recaptcha3 to my site. It works fine. But when testing it throws error.
Errror:
My works:
I'm not using .env for config. I build symfony from microkernel as per Building your own Framework with the MicroKernelTrait
CODE:
ContactType:
Here # TEST PASSES WHEN I REMOVE 'captcha' (I mentioned in above code)
ContactTypeTest:
I don't know what I'm doing wrong here.
My config:
The text was updated successfully, but these errors were encountered: