/** * @param WorkerInfo[]|ArrayCollection $workers * @return string */ protected function renderStats($workers) { $buffer = new BufferedOutput(); $buffer->setDecorated(true); $width = $this->getConsoleWidth(); $table = $width ? new AutoHidingTable($buffer, $width) : new Table($buffer); $table->setHeaders(array('Worker', 'Running', 'Total', 'PIDs')); foreach ($workers as $worker) { $table->addRow(array($worker->getName(), $worker->getNumRunning(), $worker->getTotal(), $worker->getPids()->join(', '))); } $table->render(); return $buffer->fetch(); }
/** * @param JobStats[]|ArrayCollection $statsList * @return string */ private function renderStats($statsList) { $buffer = new BufferedOutput(); $buffer->setDecorated(true); $width = $this->getConsoleWidth(); $table = $width ? new AutoHidingTable($buffer, $width) : new Table($buffer); $table->setHeaders(array('ID', 'Tube', 'State', '# Reserves', '# Releases', '# Buries', '# Kicks', 'Priority', 'Time left (secs)', '# Timeouts', 'Age (secs)', 'File')); foreach ($statsList as $stats) { $table->addRow(array($stats->id(), $stats->tube(), $stats->state(), $stats->reserves(), $stats->releases(), $stats->buries(), $stats->kicks(), $stats->priority(), in_array($stats->state(), array('reserved', 'delayed')) ? $stats->timeLeft() : 'N/A', $stats->timeouts(), $stats->age(), $stats->file() === 0 ? 'N/A' : $stats->file())); } $table->render(); return $buffer->fetch(); }
/** * @param TubeStats[]|ArrayCollection $stats * @param int|null $width * @return string */ private function renderStats(ArrayCollection $stats, $width = null) { if ($stats->isEmpty()) { return 'There are no current tubes'; } $buffer = new BufferedOutput(); $buffer->setDecorated(true); $width = $width ?: $this->getConsoleWidth(); $table = $width ? new AutoHidingTable($buffer, $width) : new Table($buffer); $table->setHeaders(array('Tube', 'Ready', 'Buried', 'Reserved', 'Delayed', 'Urgent', 'Total', '', 'Using', 'Watching', 'Waiting', '', 'Pause Elapsed', 'Pause Left', '', 'Delete Count', 'Pause Count')); foreach ($stats as $tubeStats) { $table->addRow(array($tubeStats->name(), $tubeStats->readyJobs(), $tubeStats->buriedJobs(), $tubeStats->reservedJobs(), $tubeStats->delayedJobs(), $tubeStats->urgentJobs(), $tubeStats->totalJobs(), '', $tubeStats->usingCount(), $tubeStats->watchingCount(), $tubeStats->waitingCount(), '', $tubeStats->pause(), $tubeStats->pauseTimeLeft(), '', $tubeStats->cmdDeleteCount(), $tubeStats->cmdPauseTubeCount())); } $table->render(); return $buffer->fetch(); }
public function testShouldSetPHPUnitColoredOptionOnlyIfTheOutputIsDecorated() { $files = $this->findDummyTests('DummyTest.php'); // find only one file (we don't need more for the test) // Test default commands (decorated output was disabled in setUp) $processSet = $this->creator->createFromFiles($files, [], []); /** @var Process $process */ $process = $processSet->get(ProcessSet::PROCESS_STATUS_QUEUED)[self::NAME_DUMMY_TEST]->process; $commandWithoutColors = $process->getCommandLine(); $this->assertNotContains('--colors', $commandWithoutColors); // Enable decorated output and test if the option is added to the command $this->bufferedOutput->setDecorated(true); $this->creator = new ProcessSetCreator($this->command, $this->input, $this->bufferedOutput, $this->publisherMock); $processSet = $this->creator->createFromFiles($files, [], []); /** @var Process $process */ $process = $processSet->get(ProcessSet::PROCESS_STATUS_QUEUED)[self::NAME_DUMMY_TEST]->process; $commandWithColors = $process->getCommandLine(); $this->assertContains('--colors=always', $commandWithColors); }