mediawiki-extensions-Confir.../tests/phpunit/HTMLSubmittedValueFieldTest.php
libraryupgrader 08bfd32590 build: Updating mediawiki/mediawiki-codesniffer to 16.0.0
Change-Id: Ide145e5755e0bec11fe19c18889c92a0e9d78037
2018-02-15 09:34:50 +00:00

33 lines
920 B
PHP

<?php
require_once __DIR__ . '/../../ReCaptcha/HTMLSubmittedValueField.php';
/**
* @covers HTMLSubmittedValueField
*/
class HTMLSubmittedValueFieldTest extends PHPUnit\Framework\TestCase {
public function testSubmit() {
$form = new HTMLForm( [
'foo' => [
'class' => HTMLSubmittedValueField::class,
'name' => 'bar',
],
] );
$request = new FauxRequest( [
'foo' => '123',
'bar' => '456',
], true );
$mockClosure = $this->getMockBuilder( 'object' )->setMethods( [ '__invoke' ] )->getMock();
$mockClosure->expects( $this->once() )->method( '__invoke' )
->with( [ 'foo' => '456' ] )->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();
}
}