/** * Generates the report for one single process. * * @param Process $process the current process. * * @return string The report for the current process. * * @author Christian Schäfer * @version * Version 0.1, 01.01.2007<br /> * Version 0.2, 29.12.2009 (Refactored markup)<br /> */ private function createReport4Process(Process $process) { $level = $process->getLevel(); // add closing dl only if level greater than 0 to have // correct definition list leveling! $buffer = '<dl style="margin-left: ' . $level * 20 . 'px;">'; // assemble class for the current line if ($this->lineCounter % 2 == 0) { $class = 'even'; } else { $class = 'odd'; } // increment the line counter to be able to distinguish between even and odd lines $this->lineCounter++; $buffer .= PHP_EOL; $buffer .= ' <dt class="' . $class . '">' . $process->getName() . '</dt>'; $buffer .= PHP_EOL; // add specific run time class to mark run times greater that the critical time $time = $process->getDuration(); $buffer .= ' <dd class="' . $class . ' ' . $this->getMarkedUpProcessTimeClass($time) . '">' . $time . ' s'; $buffer .= '</dd>'; $buffer .= PHP_EOL; // add closing dl only if level greater than 0 to have // correct definition list leveling! $buffer .= '</dl>'; return $buffer; }
public function testName() { $this->state->expects($this->any())->method('__toString')->willReturn('stateName'); $process = new Process('processName', '\\stdClass', 'stateName', [$this->state]); $this->assertEquals('processName', $process->getName()); }
/** * Execute a new process, and add it to the process table. * This function do not return any value, it fills the object Process received in the arguments * with the information of the new process. * * @param Process $proc The process to be executed, the attribute <b>name</b> should be filled with the application name to execute * @throws EyeInvalidArgumentException If the arguments are incorrect */ public function execute(Process $proc) { try { $processTable = $this->getProcessesTable(); do { $pid = mt_rand(ProcManager::MINPIDNUMBER, ProcManager::MAXPIDNUMBER); } while (array_key_exists($pid, $processTable)); $proc->setPid($pid); $proc->setTime(time()); $proc->setChecknum(mt_rand(ProcManager::MINCHECKNUMNUMBER, ProcManager::MAXCHECKNUMNUMBER)); //Check if we are in a context //if given process has no login context, default is to copy the current process' one if ($proc->getLoginContext() === null) { if ($this->currentProcess !== null) { $currentLoginContext = $this->currentProcess->getLoginContext(); if ($currentLoginContext !== null) { $proc->setLoginContext(clone $currentLoginContext); } else { //FIXME: TODO: move to a metadata!!!! if ($proc->getName() != 'login' && $proc->getName() != 'init' && $proc->getName() != 'register') { throw new EyeProcException('Cannot execute this application without a valid login context'); } } } } Kernel::enterSystemMode(); //when executing the first process, we need to tell the system //that our session has been activated. So regenerated is 0 if (count($processTable) == 0) { $this->memoryManager->set('regenerated', 0); } $processTable[$pid] = $proc; $this->currentProcess = $proc; $this->memoryManager->set('processTable', $processTable); Kernel::exitSystemMode(); $this->logger->debug('Process execution started: ' . $proc); $this->fireEvent('processStarted', new ProcEvent($proc)); } catch (Exception $e) { $this->logger->warn('Error executing process: ' . $proc . ' (' . $e->getMessage() . ')'); if ($this->logger->isDebugEnabled()) { $this->logger->debug(ExceptionStackUtil::getStackTrace($e, false)); } throw $e; } }