Ejemplo n.º 1
0
 /**
  * @{inheritdoc}
  */
 public function assert($data, \Hoa\Ruler\Context $context = null)
 {
     try {
         if (!$this->isInitialized()) {
             $this->initialize();
         }
         return parent::assert($data, $context);
     } catch (Exception\FalseAssertionException $e) {
         return false;
     }
 }
Ejemplo n.º 2
0
 /**
  * @param test   $test
  * @param string $methodNameToCheck
  * @return bool
  * @throws \RuntimeException
  */
 public function isMethodIgnored(test $test, $methodNameToCheck)
 {
     $contexts = array();
     foreach ($test->getTestMethods() as $methodName) {
         $contexts[$methodName] = new HoaContext();
         $contexts[$methodName]['method'] = $methodName;
         $contexts[$methodName]['class'] = $test->getClass();
         $contexts[$methodName]['namespace'] = $test->getClassNamespace();
         $contexts[$methodName]['testedclass'] = $test->getTestedClassName();
         $contexts[$methodName]['testedclassnamespace'] = $test->getTestedClassNamespace();
     }
     foreach ($test->getMandatoryMethodExtensions() as $methodName => $extensions) {
         $contexts[$methodName]['extensions'] = $extensions;
     }
     foreach ($test->getMethodTags() as $methodName => $tags) {
         $contexts[$methodName]['tags'] = $tags;
     }
     if (!isset($contexts[$methodNameToCheck])) {
         throw new \RuntimeException(sprintf('Method not found : %s', $methodNameToCheck));
     }
     return false === $this->ruler->assert($this->rule, $contexts[$methodNameToCheck]);
 }
 /**
  * Based on the data provided as arguments, decides if assertion is true.
  * 
  * @param string $context
  * @param string $operator
  * @param integer $value
  * @param integer $contextValue
  * @return boolean
  */
 public function assertion($context, $operator, $value, $contextValue)
 {
     $ruler = new Ruler();
     $cont = new Context();
     $rule = $context . " " . $operator . " " . $value;
     $cont[$context] = $contextValue;
     return $ruler->assert($rule, $cont);
 }
Ejemplo n.º 4
0
 /**
  * @param HoaRuler   $ruler
  * @param HoaContext $context
  * @param string $ruleSpace
  * @param string $ruleName
  *
  * @return bool
  */
 public function isRespectingTheRule(HoaRuler $ruler, HoaContext $context, $ruleSpace, $ruleName)
 {
     $model = $this->getRuleFromCache($ruleSpace, $ruleName);
     return $ruler->assert($model, $context);
 }