mediawiki-extensions-Confir.../tests/phpunit/HTMLReCaptchaNoCaptchaFieldTest.php
libraryupgrader bef3c335b5 build: Updating composer dependencies
* mediawiki/mediawiki-codesniffer: 35.0.0 → 36.0.0
* php-parallel-lint/php-parallel-lint: 1.2.0 → 1.3.0

Change-Id: Ib16a714334088d26d3fbaa88b5c9395fa0ab67a5
2021-05-04 04:14:03 +00:00

32 lines
887 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( stdClass::class )
->addMethods( [ '__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();
}
}