mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/ConfirmEdit
synced 2024-12-02 19:56:28 +00:00
a0feac27b0
Change-Id: I2933639f9cb50db2101c4765ce9d8f9069d253b8
48 lines
1.3 KiB
PHP
48 lines
1.3 KiB
PHP
<?php
|
|
|
|
use MediaWiki\Extension\ConfirmEdit\ReCaptchaNoCaptcha\HTMLReCaptchaNoCaptchaField;
|
|
|
|
/**
|
|
* @covers \MediaWiki\Extension\ConfirmEdit\ReCaptchaNoCaptcha\HTMLReCaptchaNoCaptchaField
|
|
*/
|
|
class HTMLReCaptchaNoCaptchaFieldTest extends MediaWikiIntegrationTestCase {
|
|
|
|
public function setUp(): void {
|
|
parent::setUp();
|
|
|
|
$this->mergeMwGlobalArrayValue(
|
|
'wgAutoloadClasses',
|
|
[
|
|
'MediaWiki\\Extension\\ConfirmEdit\\ReCaptchaNoCaptcha\\HTMLReCaptchaNoCaptchaField'
|
|
=> __DIR__ . '/../../ReCaptchaNoCaptcha/includes/HTMLReCaptchaNoCaptchaField.php'
|
|
]
|
|
);
|
|
}
|
|
|
|
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();
|
|
}
|
|
}
|