mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/ConfirmEdit
synced 2024-11-14 19:30:11 +00:00
5b7a36a521
Change-Id: Ie956fe86184535a376d0398483ac3c853fa9127c
31 lines
876 B
PHP
31 lines
876 B
PHP
<?php
|
|
|
|
/**
|
|
* @covers HTMLReCaptchaNoCaptchaField
|
|
*/
|
|
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();
|
|
}
|
|
}
|