/** * @return WpTesting_Model_Formula */ public function getFormula() { $empty = new WpTesting_Model_Formula(); $empty->setResultId($this->getId()); if (is_null($this->test)) { return $empty; } $empty->setTestId($this->test->getId()); /* @var $formulas fRecordSet */ $formulas = $this->test->buildFormulas(); foreach ($formulas->filter(array('getResultId=' => $this->getId())) as $formula) { return $formula; } return $empty; }
public function validateSource(WpTesting_Model_Formula $me, &$values, &$oldValues, &$relatedRecords, &$cache, &$validationMessages) { /* @var $test WpTesting_Model_Test */ $test = $me->createWpTesting_Model_Test()->setWp($this->getWp()); $varNames = array(); foreach ($test->buildFormulaVariables() as $var) { $varNames[] = $var->getSource(); } if ($me->isCorrect($varNames)) { return; } /* @var $result WpTesting_Model_Result */ $result = $me->createWpTesting_Model_Result(); $validationMessages['formula_source'] = sprintf(__('Formula for %s has error', 'wp-testing'), $result->getTitle()); }