public function MathfieldWidgetTestCase::testMathfieldReadOnlyWidget in Math Field 7
File
- ./
mathfield.test, line 189 - Tests for mathfield.module.
Class
- MathfieldWidgetTestCase
- Test math field widgets.
Code
public function testMathfieldReadOnlyWidget() {
$this
->createField('field_a', 'A', 'number_integer');
$this
->createField('field_b', 'B', 'number_integer');
// Create a math expression text widget to add the integers.
$a = $this
->randInteger();
$b = $this
->randInteger();
$result = number_format($a + $b, 2, '.', '');
$this
->createMathExpressionField('field_a_b', 'A + B', '[field_a] + [field_b]', 'mathfield_markup');
// Go to the node add page and make sure the text field exists.
$this
->drupalGet('node/add/math');
$this
->assertText('A + B', 'Math expression read-only widget is displayed on the node add form.');
// Create a new math node.
$edit = array();
$edit['title'] = $this
->randomName(8);
$edit["field_a[und][0][value]"] = $a;
$edit["field_b[und][0][value]"] = $b;
$this
->drupalPost('node/add/math', $edit, t('Save'));
$this
->assertText($result, 'Evaluated the math expression read-only widget.');
// Make sure the result is displayed on the edit form.
$this
->clickLink(t('Edit'));
$this
->assertText($result, 'Math expression read-only widget is displayed on the edit form.');
}