mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/ConfirmEdit
synced 2024-11-15 11:59:33 +00:00
e1f45829d4
Change-Id: I1e99261acb13c86e96c1b2dd1cb61918ebc660c2
33 lines
961 B
PHP
33 lines
961 B
PHP
<?php
|
|
|
|
require_once __DIR__ . '/../../ReCaptchaNoCaptcha/HTMLReCaptchaNoCaptchaField.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();
|
|
}
|
|
}
|