diff options
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(); + } +} |