blob: 042d184bb217dddd901594fdb059aa095cfef022 (
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
<?php
namespace SMW\Tests\MediaWiki\Search\Form;
use SMW\MediaWiki\Search\Form\CustomForm;
/**
* @covers \SMW\MediaWiki\Search\Form\CustomForm
* @group semantic-mediawiki
*
* @license GNU GPL v2+
* @since 3.0
*
* @author mwjames
*/
class CustomFormTest extends \PHPUnit_Framework_TestCase {
private $webRequest;
protected function setUp() {
$this->webRequest = $this->getMockBuilder( '\WebRequest' )
->disableOriginalConstructor()
->getMock();
}
public function testCanConstruct() {
$this->assertInstanceOf(
CustomForm::class,
new CustomForm( $this->webRequest )
);
}
public function testMakeFields() {
$this->webRequest->expects( $this->at( 0 ) )
->method( 'getArray' )
->with( $this->equalTo( 'barproperty' ) )
->will( $this->returnValue( [ 1001 ] ) );
$instance = new CustomForm(
$this->webRequest
);
$instance->isActiveForm( true );
$form = [
'<div class="smw-input-field" style="display:inline-block;">',
'<input class="smw-input" name="barproperty[]" value="1001" placeholder="Bar property ..." ',
'data-property="Bar property" title="Bar property"/></div>'
];
$this->assertContains(
implode( '', $form ),
$instance->makeFields( [ 'Bar property'] )
);
$this->assertEquals(
[
'barproperty' => 1001
],
$instance->getParameters()
);
}
}
|