예제 #1
0
 public function testSetProbability()
 {
     $gc = new GarbageCollector();
     try {
         $gc->setProbability(-99);
     } catch (\UnexpectedValueException $e) {
         $this->assertEquals('Probability must be equal or greather than 1', $e->getMessage());
     }
     $this->assertEquals(1, $gc->getProbability());
     $gc->setProbability(50);
     $this->assertEquals(50, $gc->getProbability());
 }
예제 #2
0
 /**
  *
  * {@inheritDoc}
  * @see \PHPLegends\Session\SessionInterface::close()
  */
 public function close()
 {
     $this->write();
     if ($this->lifetime > 0) {
         setcookie($this->getName(), $this->getId(), $this->lifetime + time());
     } else {
         setcookie($this->getName(), $this->getId());
     }
     if ($this->gc->passes()) {
         $this->getHandler()->gc($this->gc->getMaxLifetime());
     }
     $this->closed = true;
 }