diff options
author | Yaco <franco@reevo.org> | 2020-06-04 11:01:00 -0300 |
---|---|---|
committer | Yaco <franco@reevo.org> | 2020-06-04 11:01:00 -0300 |
commit | fc7369835258467bf97eb64f184b93691f9a9fd5 (patch) | |
tree | daabd60089d2dd76d9f5fb416b005fbe159c799d /www/wiki/extensions/ConfirmEdit/tests/HTMLReCaptchaNoCaptchaFieldTest.php |
first commit
Diffstat (limited to 'www/wiki/extensions/ConfirmEdit/tests/HTMLReCaptchaNoCaptchaFieldTest.php')
-rw-r--r-- | www/wiki/extensions/ConfirmEdit/tests/HTMLReCaptchaNoCaptchaFieldTest.php | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/www/wiki/extensions/ConfirmEdit/tests/HTMLReCaptchaNoCaptchaFieldTest.php b/www/wiki/extensions/ConfirmEdit/tests/HTMLReCaptchaNoCaptchaFieldTest.php new file mode 100644 index 00000000..5305db22 --- /dev/null +++ b/www/wiki/extensions/ConfirmEdit/tests/HTMLReCaptchaNoCaptchaFieldTest.php @@ -0,0 +1,29 @@ +<?php + +require_once __DIR__ . '/../ReCaptchaNoCaptcha/HTMLReCaptchaNoCaptchaField.php'; + +class HTMLReCaptchaNoCaptchaFieldTest extends PHPUnit_Framework_TestCase { + public function testSubmit() { + $form = new HTMLForm( [ + 'foo' => [ + 'class' => HTMLReCaptchaNoCaptchaField::class, + 'key' => '123', + ], + ] ); + $request = new FauxRequest( [ + 'foo' => 'abc', + 'g-recaptcha-response' => 'def', + ], true ); + $mockClosure = $this->getMockBuilder( 'object' )->setMethods( [ '__invoke' ] )->getMock(); + $mockClosure->expects( $this->once() )->method( '__invoke' ) + ->with( [ 'foo' => 'def' ] )->willReturn( true ); + + $context = new DerivativeContext( RequestContext::getMain() ); + $context->setRequest( $request ); + $form->setTitle( Title::newFromText( 'Title' ) ); + $form->setContext( $context ); + $form->setSubmitCallback( $mockClosure ); + $form->prepareForm(); + $form->trySubmit(); + } +} |