public function RulesFormsConditionsTestCase::testElementValueChangedCondition in Rules Forms Support 7
Same name and namespace in other branches
- 7.2 rules_forms.test \RulesFormsConditionsTestCase::testElementValueChangedCondition()
Tests callback for Condition: Element value has changed.
File
- ./
rules_forms.test, line 458 - Stores tests related to Rules Form.
Class
- RulesFormsConditionsTestCase
- Tests Rules Forms conditions.
Code
public function testElementValueChangedCondition() {
$form = self::$form;
$form_state = self::$formState;
// rules_forms_event_build will set build information variables.
variable_set('rules_forms_form_info', self::$formInfo);
rules_forms_event_build($form, $form_state, self::$formId);
// Execute condition without changing the value.
$form_state['values']['title'] = 'tset';
$condition1 = rules_condition('rules_forms_element_changed', array(
'element' => 'textfield:title',
));
$result1 = $condition1
->executeByArgs(array(
'form' => $form,
'form_state' => $form_state,
));
$this
->assertFalse($result1, 'Form value has not changed.');
// Execute condition with changing the value.
$form_state['values']['title'] = 'test';
$condition2 = rules_condition('rules_forms_element_changed', array(
'element' => 'textfield:title',
));
$result2 = $condition2
->executeByArgs(array(
'form' => $form,
'form_state' => $form_state,
));
$this
->assertTrue($result2, 'Form value has changed.');
}