public function testIsPassed() { // Test that a 2 second limit passes as expected $now = new \DateTime(); $limit = new TimeLimit(5, 'dummy'); $this->assertFalse($limit->isPassed($now)); $now->modify('-6 seconds'); $this->assertTrue($limit->isPassed($now)); }
/** * Check if the time limit has passed if one exists * NOTE: this method will return null if the time limit is not set * * @param DateTime $started When the context was placed in the state * * @return State|null Time limit followup state if the limit is passed, null elsewise */ public function hasTimeLimitPassed(\DateTime $started) { if ($this->hasTimeLimit()) { if ($this->timeLimit->isPassed($started)) { return $this->timeLimit->getState(); } else { return null; } } else { return null; // Cant be passed a non-existent time limit } }