2016-05-03 16:42:00 +00:00
|
|
|
<?php
|
|
|
|
|
2018-01-23 23:59:08 +00:00
|
|
|
/**
|
|
|
|
* @covers HTMLSubmittedValueField
|
|
|
|
*/
|
2018-02-15 09:34:50 +00:00
|
|
|
class HTMLSubmittedValueFieldTest extends PHPUnit\Framework\TestCase {
|
2016-05-03 16:42:00 +00:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
}
|