Alex\BehatLauncher\Workspace::startUnits PHP Method

startUnits() private method

private startUnits ( ) : integer
return integer number of started units
    private function startUnits()
    {
        $count = 0;
        $projectList = $this->projectList->getAll();
        $project = array_pop($projectList);
        while (true) {
            // verify a project is up
            if (null === $project) {
                break;
            }
            // verify project has not reached running limit
            if (isset($this->runningUnits[$project->getName()]) && count($this->runningUnits[$project->getName()]) >= $project->getRunnerCount()) {
                $project = array_pop($projectList);
                continue;
            }
            $runnable = $this->runStorage->getRunnableUnit($project);
            if (!$runnable) {
                $project = array_pop($projectList);
                continue;
            }
            $this->output('starting unit #' . $runnable->getId());
            if (!isset($this->runningUnits[$project->getName()])) {
                $this->runningUnits[$project->getName()] = array();
            }
            $runnable->prepareOutput($project);
            $this->runStorage->saveRunUnit($runnable);
            $runnable->start($project, function ($text, $error) use($runnable) {
                $this->output($text, $runnable, $error);
            });
            $this->runningUnits[$project->getName()][] = $runnable;
            $count++;
        }
        return $count;
    }