silverstripe-userforms/tests/EditableCustomRuleTest.php

31 lines
1.0 KiB
PHP
Raw Normal View History

<?php
/**
* Class EditableCustomRulesTest
*/
class EditableCustomRuleTest extends SapphireTest
{
protected static $fixture_file = 'userforms/tests/EditableCustomRuleTest.yml';
public function testBuildExpression()
{
/** @var EditableCustomRule $rule1 */
$rule1 = $this->objFromFixture('EditableCustomRule', 'rule1');
$result1 = $rule1->buildExpression();
//Dropdowns expect change event
$this->assertEquals('change', $result1['event']);
$this->assertNotEmpty($result1['operation']);
//Check for equals sign
$this->assertContains('==', $result1['operation']);
/** @var EditableCustomRule $rule2 */
$rule2 = $this->objFromFixture('EditableCustomRule', 'rule2');
$result2 = $rule2->buildExpression();
//TextField expect change event
$this->assertEquals('keyup', $result2['event']);
$this->assertNotEmpty($result2['operation']);
//Check for greater than sign
$this->assertContains('>', $result2['operation']);
}
}