2016-05-03 16:42:00 +00:00
|
|
|
<?php
|
|
|
|
|
2018-01-23 23:59:08 +00:00
|
|
|
/**
|
|
|
|
* @covers HTMLReCaptchaNoCaptchaField
|
|
|
|
*/
|
2018-02-15 09:34:50 +00:00
|
|
|
class HTMLReCaptchaNoCaptchaFieldTest extends PHPUnit\Framework\TestCase {
|
2016-05-03 16:42:00 +00:00
|
|
|
public function testSubmit() {
|
2022-05-15 21:35:03 +00:00
|
|
|
$request = new FauxRequest( [
|
|
|
|
'foo' => 'abc',
|
|
|
|
'g-recaptcha-response' => 'def',
|
|
|
|
], true );
|
|
|
|
$context = new DerivativeContext( RequestContext::getMain() );
|
|
|
|
$context->setRequest( $request );
|
|
|
|
|
2016-05-03 16:42:00 +00:00
|
|
|
$form = new HTMLForm( [
|
|
|
|
'foo' => [
|
|
|
|
'class' => HTMLReCaptchaNoCaptchaField::class,
|
|
|
|
'key' => '123',
|
|
|
|
],
|
2022-05-15 21:35:03 +00:00
|
|
|
], $context );
|
|
|
|
|
2018-10-09 12:09:10 +00:00
|
|
|
$mockClosure = $this->getMockBuilder( stdClass::class )
|
2021-05-03 07:10:28 +00:00
|
|
|
->addMethods( [ '__invoke' ] )->getMock();
|
2016-05-03 16:42:00 +00:00
|
|
|
$mockClosure->expects( $this->once() )->method( '__invoke' )
|
|
|
|
->with( [ 'foo' => 'def' ] )->willReturn( true );
|
|
|
|
|
|
|
|
$form->setTitle( Title::newFromText( 'Title' ) );
|
|
|
|
$form->setSubmitCallback( $mockClosure );
|
|
|
|
$form->prepareForm();
|
|
|
|
$form->trySubmit();
|
|
|
|
}
|
|
|
|
}
|