2016-05-03 16:42:00 +00:00
|
|
|
<?php
|
|
|
|
|
2016-08-05 17:15:41 +00:00
|
|
|
require_once __DIR__ . '/../../ReCaptchaNoCaptcha/HTMLReCaptchaNoCaptchaField.php';
|
2016-05-03 16:42:00 +00:00
|
|
|
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
}
|