public function MathfieldTokenTestCase::testMathfieldMathfieldTokens in Math Field 7
Tests using another math field as a tokens in a math expression.
File
- ./
mathfield.test, line 293 - Tests for mathfield.module.
Class
- MathfieldTokenTestCase
- Test tokens in math expression fields.
Code
public function testMathfieldMathfieldTokens() {
// Create some simple integer fields.
$this
->createField('field_a', 'A', 'number_integer');
$this
->createField('field_b', 'B', 'number_integer');
// Create a math expression to add the integers.
$a = $this
->randInteger();
$b = $this
->randInteger();
$sum = number_format($a + $b, 2, '.', '');
$this
->createMathExpressionField('field_a_b', 'A + B', '[field_a] + [field_b]');
// Create a math expression to double the result.
$result = number_format(($a + $b) * 2, 2, '.', '');
$this
->createMathExpressionField('field_result', 'Result', '[field_a_b] * 2');
// 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($sum, 'Evaluated the dependent math expression.');
$this
->assertText($result, 'Evaluated a math expression using tokens from another math field.');
}