mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/ConfirmEdit
synced 2024-11-28 01:50:18 +00:00
08bfd32590
Change-Id: Ide145e5755e0bec11fe19c18889c92a0e9d78037
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();
|
|
}
|
|
}
|