コード例 #1
0
 public function testIsApplicableTo()
 {
     $badgeRule = new BadgeRule();
     $badgeRule->setOccurrence(rand(0, PHP_INT_MAX));
     $occurenceConstraint = new ResultConstraint();
     $this->assertFalse($occurenceConstraint->isApplicableTo($badgeRule));
 }
コード例 #2
0
 public function testValidateTwoRightOneWrongLogLogResultSuperiorEqual()
 {
     $result = rand(0, PHP_INT_MAX / 2);
     $badgeRule = new BadgeRule();
     $badgeRule->setOccurrence(1)->setResult($result)->setResultComparison(4);
     $log = new Log();
     $log->setDetails(array('result' => $result + rand(0, PHP_INT_MAX / 2)));
     $log2 = new Log();
     $log2->setDetails(array('result' => $result - 1));
     $log3 = new Log();
     $log3->setDetails(array('result' => $result + rand(0, PHP_INT_MAX / 2)));
     $associatedLogs = array($log, $log2, $log3);
     $resultConstraint = new ResultConstraint();
     $resultConstraint->setRule($badgeRule)->setAssociatedLogs($associatedLogs);
     $this->assertTrue($resultConstraint->validate());
 }