mediawiki-extensions-Confir.../tests/phpunit/HTMLSubmittedValueFieldTest.php
Aryeh Gregor 422dccc7b0 Do not attempt to mock 'object'
This doesn't work in PHP 7.2, because 'object' is no longer a valid
class name.  stdClass works fine.

Change-Id: I47375fdf2f36ff62985b2e8c90fa0e5230273984
2018-10-09 15:10:33 +03:00

32 lines
859 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( stdClass::class )
->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();
}
}