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