1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Class EditableCustomRulesTest |
5
|
|
|
*/ |
6
|
|
|
class EditableCustomRuleTest extends SapphireTest |
|
|
|
|
7
|
|
|
{ |
8
|
|
|
protected static $fixture_file = 'userforms/tests/EditableCustomRuleTest.yml'; |
9
|
|
|
|
10
|
|
|
public function testBuildExpression() |
11
|
|
|
{ |
12
|
|
|
/** @var EditableCustomRule $rule1 */ |
13
|
|
|
$rule1 = $this->objFromFixture('EditableCustomRule', 'rule1'); |
14
|
|
|
$result1 = $rule1->buildExpression(); |
15
|
|
|
|
16
|
|
|
//Dropdowns expect change event |
17
|
|
|
$this->assertEquals('change', $result1['event']); |
|
|
|
|
18
|
|
|
$this->assertNotEmpty($result1['operation']); |
|
|
|
|
19
|
|
|
//Check for equals sign |
20
|
|
|
$this->assertContains('==', $result1['operation']); |
21
|
|
|
|
22
|
|
|
/** @var EditableCustomRule $rule2 */ |
23
|
|
|
$rule2 = $this->objFromFixture('EditableCustomRule', 'rule2'); |
24
|
|
|
$result2 = $rule2->buildExpression(); |
25
|
|
|
//TextField expect change event |
26
|
|
|
$this->assertEquals('keyup', $result2['event']); |
|
|
|
|
27
|
|
|
$this->assertNotEmpty($result2['operation']); |
|
|
|
|
28
|
|
|
//Check for greater than sign |
29
|
|
|
$this->assertContains('>', $result2['operation']); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Test that methods are returned for manipulating the presence of the "hide" CSS class depending |
34
|
|
|
* on whether the field should be hidden or shown |
35
|
|
|
*/ |
36
|
|
|
public function testToggleDisplayText() |
37
|
|
|
{ |
38
|
|
|
$rule1 = $this->objFromFixture('EditableCustomRule', 'rule1'); |
39
|
|
|
$this->assertSame('addClass("hide")', $rule1->toggleDisplayText('show')); |
|
|
|
|
40
|
|
|
$this->assertSame('removeClass("hide")', $rule1->toggleDisplayText('hide')); |
|
|
|
|
41
|
|
|
} |
42
|
|
|
} |
43
|
|
|
|
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.