mediawiki-extensions-Confir.../tests/phpunit/HTMLSubmittedValueFieldTest.php
Reedy 6a8c53f6d1 Remove 'UnitTestList' hook
No longer needed now that extension unittests are autodiscovered.

Bug: T142120
Bug: T142121
Change-Id: I7105170e56c8c3ec3837dd15be869e503bccecde
2016-08-05 18:46:15 +01:00

30 lines
877 B
PHP

<?php
require_once __DIR__ . '/../../ReCaptcha/HTMLSubmittedValueField.php';
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();
}
}