mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/ConfirmEdit
synced 2024-12-11 07:46:27 +00:00
5b7a36a521
Change-Id: Ie956fe86184535a376d0398483ac3c853fa9127c
31 lines
848 B
PHP
31 lines
848 B
PHP
<?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();
|
|
}
|
|
}
|