Exemplo n.º 1
0
 function testSimpleOperationPreparsed()
 {
     $parser = new Math_Formula_Parser();
     $element = $parser->parse('(mul (add 1 2) test)');
     $this->runner->setFormula($element);
     $required = $this->runner->inspect();
     $this->assertEquals(array('test'), $required);
 }
Exemplo n.º 2
0
 private function getElement($element)
 {
     if (is_string($element)) {
         $parser = new Math_Formula_Parser();
         $element = $parser->parse($element);
     }
     return $element;
 }
Exemplo n.º 3
0
 private function getRule($id)
 {
     if (!($rule = $this->lib->getRule($id))) {
         $rule = array('ruleId' => null, 'eventType' => '', 'notes' => '', 'rule' => '');
     }
     if ($rule['rule']) {
         $parser = new Math_Formula_Parser();
         $rule['element'] = $parser->parse($rule['rule']);
     } else {
         $rule['element'] = null;
     }
     return $rule;
 }
Exemplo n.º 4
0
 private function get_initialized_configurations()
 {
     if ($this->configurations) {
         return $this->configurations;
     }
     $ratingconfiglib = TikiLib::lib('ratingconfig');
     $parser = new Math_Formula_Parser();
     $configurations = array();
     foreach ($ratingconfiglib->get_configurations() as $config) {
         $config['formula'] = $parser->parse($config['formula']);
         $configurations[] = $config;
     }
     return $this->configurations = $configurations;
 }
Exemplo n.º 5
0
 private function internal_refresh_list($max)
 {
     global $ratingconfiglib;
     require_once 'lib/rating/configlib.php';
     // Pre-parse formulas to avoid doing it multiple times
     require_once 'Math/Formula/Parser.php';
     $parser = new Math_Formula_Parser();
     $configurations = array();
     foreach ($ratingconfiglib->get_configurations() as $config) {
         $config['formula'] = $parser->parse($config['formula']);
         $configurations[] = $config;
     }
     $runner = $this->get_runner();
     $list = $ratingconfiglib->get_expired_object_list($max);
     foreach ($list as $object) {
         $this->internal_refresh_rating($object['type'], $object['object'], $runner, $configurations);
     }
 }
Exemplo n.º 6
0
 /**
  * @dataProvider badStrings
  * @expectedException Math_Formula_Parser_Exception
  */
 function testBadParse($string)
 {
     $parser = new Math_Formula_Parser();
     $parser->parse($string);
 }