%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /data/www_bck/varak.net_bck/warhammer.varak.net/vendor/nette/tester/src/Runner/Output/
Upload File :
Create Path :
Current File : //data/www_bck/varak.net_bck/warhammer.varak.net/vendor/nette/tester/src/Runner/Output/Logger.php

<?php

/**
 * This file is part of the Nette Tester.
 * Copyright (c) 2009 David Grudl (https://davidgrudl.com)
 */

namespace Tester\Runner\Output;

use Tester;
use Tester\Runner\Runner;
use Tester\Runner\Test;


/**
 * Verbose logger.
 */
class Logger implements Tester\Runner\OutputHandler
{
	/** @var Runner */
	private $runner;

	/** @var resource */
	private $file;

	/** @var int */
	private $count;

	/** @var array */
	private $results;


	public function __construct(Runner $runner, $file = 'php://output')
	{
		$this->runner = $runner;
		$this->file = fopen($file, 'w');
	}


	public function begin()
	{
		$this->count = 0;
		$this->results = [
			Test::PASSED => 0,
			Test::SKIPPED => 0,
			Test::FAILED => 0,
		];
		fwrite($this->file, 'PHP ' . $this->runner->getInterpreter()->getVersion()
			. ' | ' . $this->runner->getInterpreter()->getCommandLine()
			. " | {$this->runner->threadCount} threads\n\n");
	}


	public function prepare(Test $test)
	{
		$this->count++;
	}


	public function finish(Test $test)
	{
		$this->results[$test->getResult()]++;
		$message = '   ' . str_replace("\n", "\n   ", Tester\Dumper::removeColors(trim($test->message)));
		$outputs = [
			Test::PASSED => "-- OK: {$test->getSignature()}",
			Test::SKIPPED => "-- Skipped: {$test->getSignature()}\n$message",
			Test::FAILED => "-- FAILED: {$test->getSignature()}\n$message",
		];
		fwrite($this->file, $outputs[$test->getResult()] . "\n\n");
	}


	public function end()
	{
		$run = array_sum($this->results);
		fwrite($this->file,
			($this->results[Test::FAILED] ? 'FAILURES!' : 'OK')
			. " ($this->count tests"
			. ($this->results[Test::FAILED] ? ", {$this->results[Test::FAILED]} failures" : '')
			. ($this->results[Test::SKIPPED] ? ", {$this->results[Test::SKIPPED]} skipped" : '')
			. ($this->count !== $run ? ', ' . ($this->count - $run) . ' not run' : '')
			. ')'
		);
	}
}

Zerion Mini Shell 1.0