/**
  * Gets the Timer bound to the test session
  * @return QtiTimer
  * @throws \oat\taoTests\models\runner\time\InvalidDataException
  * @throws \oat\taoTests\models\runner\time\InvalidStorageException
  */
 public function getTimer()
 {
     if (!$this->timer) {
         $this->timer = new QtiTimer();
         $this->timer->setStorage(new QtiTimeStorage($this->getSessionId(), $this->getUserUri()));
         $this->timer->load();
     }
     return $this->timer;
 }
 /**
  * Gets the delivery time counter
  *
  * @param \taoDelivery_models_classes_execution_DeliveryExecution $deliveryExecution
  * @return QtiTimer
  * @throws \oat\oatbox\service\ServiceNotFoundException
  */
 public static function getDeliveryTimer($deliveryExecution)
 {
     if (is_string($deliveryExecution)) {
         $deliveryExecution = self::getDeliveryExecutionById($deliveryExecution);
     }
     $testSessionService = ServiceManager::getServiceManager()->get(TestSessionService::SERVICE_ID);
     $testSession = $testSessionService->getTestSession($deliveryExecution);
     if ($testSession instanceof TestSession) {
         $timer = $testSession->getTimer();
     } else {
         $timer = new QtiTimer();
         $timer->setStorage(new QtiTimeStorage($deliveryExecution->getIdentifier(), $deliveryExecution->getUserIdentifier()));
         $timer->load();
     }
     return $timer;
 }
 /**
  * @expectedException \oat\taoTests\models\runner\time\InvalidStorageException
  */
 public function testLoadInvalidStorageException()
 {
     $timer = new QtiTimer();
     $timer->load();
 }