MediaWiki REL1_31
HTMLReCaptchaNoCaptchaFieldTest.php
Go to the documentation of this file.
1<?php
2
3require_once __DIR__ . '/../../ReCaptchaNoCaptcha/HTMLReCaptchaNoCaptchaField.php';
4
8class HTMLReCaptchaNoCaptchaFieldTest extends PHPUnit\Framework\TestCase {
9 public function testSubmit() {
10 $form = new HTMLForm( [
11 'foo' => [
12 'class' => HTMLReCaptchaNoCaptchaField::class,
13 'key' => '123',
14 ],
15 ] );
16 $request = new FauxRequest( [
17 'foo' => 'abc',
18 'g-recaptcha-response' => 'def',
19 ], true );
20 $mockClosure = $this->getMockBuilder( stdClass::class )
21 ->setMethods( [ '__invoke' ] )->getMock();
22 $mockClosure->expects( $this->once() )->method( '__invoke' )
23 ->with( [ 'foo' => 'def' ] )->willReturn( true );
24
26 $context->setRequest( $request );
27 $form->setTitle( Title::newFromText( 'Title' ) );
28 $form->setContext( $context );
29 $form->setSubmitCallback( $mockClosure );
30 $form->prepareForm();
31 $form->trySubmit();
32 }
33}
An IContextSource implementation which will inherit context from another source but allow individual ...
WebRequest clone which takes values from a provided array.
Object handling generic submission, CSRF protection, layout and other logic for UI forms.
Definition HTMLForm.php:130
static getMain()
Get the RequestContext object associated with the main request.
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on $request
Definition hooks.txt:2806
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on and they can depend only on the ResourceLoaderContext $context
Definition hooks.txt:2811