mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/ConfirmEdit
synced 2024-12-21 04:13:03 +00:00
5880031d1c
Change-Id: I8777b2b2d6a87695f6517f259f31a177356ac8f5
33 lines
866 B
PHP
33 lines
866 B
PHP
<?php
|
|
|
|
/**
|
|
* @covers HTMLReCaptchaNoCaptchaField
|
|
*/
|
|
class HTMLReCaptchaNoCaptchaFieldTest extends PHPUnit\Framework\TestCase {
|
|
public function testSubmit() {
|
|
$request = new FauxRequest( [
|
|
'foo' => 'abc',
|
|
'g-recaptcha-response' => 'def',
|
|
], true );
|
|
$context = new DerivativeContext( RequestContext::getMain() );
|
|
$context->setRequest( $request );
|
|
|
|
$form = new HTMLForm( [
|
|
'foo' => [
|
|
'class' => HTMLReCaptchaNoCaptchaField::class,
|
|
'key' => '123',
|
|
],
|
|
], $context );
|
|
|
|
$mockClosure = $this->getMockBuilder( stdClass::class )
|
|
->addMethods( [ '__invoke' ] )->getMock();
|
|
$mockClosure->expects( $this->once() )->method( '__invoke' )
|
|
->with( [ 'foo' => 'def' ] )->willReturn( true );
|
|
|
|
$form->setTitle( Title::newFromText( 'Title' ) );
|
|
$form->setSubmitCallback( $mockClosure );
|
|
$form->prepareForm();
|
|
$form->trySubmit();
|
|
}
|
|
}
|