MediaWiki REL1_31
HTMLReCaptchaFieldTest.php
Go to the documentation of this file.
1<?php
2
3require_once __DIR__ . '/../../ReCaptcha/HTMLReCaptchaField.php';
4
8class HTMLReCaptchaFieldTest extends PHPUnit\Framework\TestCase {
9 public function testSubmit() {
10 $form = new HTMLForm( [
11 'foo' => [
12 'class' => HTMLReCaptchaField::class,
13 'key' => '123',
14 'theme' => 'x',
15 ],
16 ] );
17 $mockClosure = $this->getMockBuilder( stdClass::class )
18 ->setMethods( [ '__invoke' ] )->getMock();
19 $mockClosure->expects( $this->once() )->method( '__invoke' )
20 ->with( [] )->willReturn( true );
21
22 $form->setTitle( Title::newFromText( 'Title' ) );
23 $form->setSubmitCallback( $mockClosure );
24 $form->prepareForm();
25 $form->trySubmit();
26 }
27}
Object handling generic submission, CSRF protection, layout and other logic for UI forms.
Definition HTMLForm.php:130