summaryrefslogtreecommitdiff
path: root/www/wiki/extensions/ConfirmEdit/tests/HTMLSubmittedValueFieldTest.php
blob: 1fdb015aae27304e65ef290d02c8ba28db8f4ebd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?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();
	}
}