1
|
|
|
<?php |
2
|
|
|
namespace Mezon\Gui\Tests; |
3
|
|
|
|
4
|
|
|
class CustomFieldUnitTest extends \PHPUnit\Framework\TestCase |
5
|
|
|
{ |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Method returns mock object of the custom field |
9
|
|
|
* |
10
|
|
|
* @return object mock object of the custom field |
11
|
|
|
*/ |
12
|
|
|
protected function getFieldMock(): object |
13
|
|
|
{ |
14
|
|
|
$mock = $this->getMockBuilder(\Mezon\Gui\Field\CustomField::class) |
|
|
|
|
15
|
|
|
->setConstructorArgs( |
16
|
|
|
[ |
17
|
|
|
[ |
18
|
|
|
'name' => 'name', |
19
|
|
|
'required' => 1, |
20
|
|
|
'disabled' => 1, |
21
|
|
|
'custom' => 1, |
22
|
|
|
'name-prefix' => 'prefix', |
23
|
|
|
'batch' => 1, |
24
|
|
|
'toggler' => 'toggler-name', |
25
|
|
|
'toggle-value' => 3, |
26
|
|
|
'type' => 'integer', |
27
|
|
|
'fields' => [], |
28
|
|
|
'class' => 'cls' |
29
|
|
|
], |
30
|
|
|
'' |
31
|
|
|
]) |
32
|
|
|
->setMethods([ |
33
|
|
|
'get_field_template' |
34
|
|
|
]) |
35
|
|
|
->getMock(); |
36
|
|
|
|
37
|
|
|
$mock->method('get_field_template')->willReturn( |
38
|
|
|
'class:{class} name:{name} required:{required} disabled:{disabled} custom:{custom} name-prefix:{name-prefix} batch:{batch} toggler:{toggler} toggler:{toggle-value}'); |
39
|
|
|
|
40
|
|
|
return $mock; |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* Testing constructor |
45
|
|
|
*/ |
46
|
|
|
public function testConstructor() |
47
|
|
|
{ |
48
|
|
|
// setup |
49
|
|
|
$field = $this->getFieldMock(); |
50
|
|
|
|
51
|
|
|
// test body |
52
|
|
|
$content = $field->html(); |
53
|
|
|
|
54
|
|
|
// assertions |
55
|
|
|
$this->assertStringContainsString('name:name', $content); |
56
|
|
|
$this->assertStringContainsString('required:1', $content); |
57
|
|
|
$this->assertStringContainsString('disabled:1', $content); |
58
|
|
|
$this->assertStringContainsString('custom:1', $content); |
59
|
|
|
$this->assertStringContainsString('name-prefix:prefix', $content); |
60
|
|
|
$this->assertStringContainsString('batch:1', $content); |
61
|
|
|
$this->assertStringContainsString('toggler:toggler-name', $content); |
62
|
|
|
$this->assertStringContainsString('toggler:3', $content); |
63
|
|
|
$this->assertStringContainsString('class:cls', $content); |
64
|
|
|
} |
65
|
|
|
} |
66
|
|
|
|
This function has been deprecated. The supplier of the function has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.