You are here

public function MathfieldTokenTestCase::testMathfieldBasicTokens in Math Field 7

Tests basic tokens in math expression fields.

File

./mathfield.test, line 234
Tests for mathfield.module.

Class

MathfieldTokenTestCase
Test tokens in math expression fields.

Code

public function testMathfieldBasicTokens() {

  // Create some basic numeric text fields.
  $this
    ->createField('field_integer', 'Integer', 'number_integer');
  $this
    ->createField('field_float', 'Float', 'number_float');

  // Add an integer and float.
  $a = $this
    ->randInteger();
  $b = $this
    ->randFloat();
  $result = number_format($a + $b, 2, '.', '');
  $this
    ->createMathExpressionField('field_basic', 'Basic', '[field_integer] + [field_float]');

  // Create a new math node.
  $edit = array();
  $edit['title'] = $this
    ->randomName(8);
  $edit["field_integer[und][0][value]"] = $a;
  $edit["field_float[und][0][value]"] = $b;
  $this
    ->drupalPost('node/add/math', $edit, t('Save'));
  $this
    ->assertText($result, 'Evaluated a math expression using basic tokens.');
}