Overview

Namespaces

  • Budovy
  • Kdyby
    • BootstrapFormRenderer
      • DI
      • Latte
  • Nette
    • Application
      • Diagnostics
      • Responses
      • Routers
      • UI
    • Caching
      • Storages
    • ComponentModel
    • Database
      • Diagnostics
      • Drivers
      • Reflection
      • Table
    • DI
      • Config
        • Adapters
      • Diagnostics
      • Extensions
    • Diagnostics
    • Forms
      • Controls
      • Rendering
    • Http
      • Diagnostics
    • Iterators
    • Latte
      • Macros
    • Loaders
    • Localization
    • Mail
    • PhpGenerator
    • Reflection
    • Security
      • Diagnostics
    • Templating
    • Utils
  • NetteModule
  • Nextras
    • Datagrid
  • None
  • PHP
  • Tester
    • CodeCoverage
    • Runner
      • Output
  • Vodacek
    • Forms
      • Controls
  • WebLoader
    • Filter
    • Nette

Classes

  • ConsolePrinter
  • Logger
  • TapPrinter
  • Overview
  • Namespace
  • Class
  • Tree
 1: <?php
 2: 
 3: /**
 4:  * This file is part of the Nette Tester.
 5:  * Copyright (c) 2009 David Grudl (http://davidgrudl.com)
 6:  */
 7: 
 8: namespace Tester\Runner\Output;
 9: 
10: use Tester,
11:     Tester\Runner\Runner;
12: 
13: 
14: /**
15:  * File logger.
16:  *
17:  * @author     David Grudl
18:  */
19: class Logger implements Tester\Runner\OutputHandler
20: {
21:     /** @var Runner */
22:     private $runner;
23: 
24:     /** @var resource */
25:     private $file;
26: 
27: 
28:     public function __construct(Runner $runner, $file)
29:     {
30:         $this->runner = $runner;
31:         $this->file = fopen($file, 'w');
32:     }
33: 
34: 
35:     public function begin()
36:     {
37:         fputs($this->file, 'PHP ' . $this->runner->getPhp()->getVersion()
38:             . ' | ' . $this->runner->getPhp()->getCommandLine()
39:             . " | {$this->runner->threadCount} threads\n\n");
40:     }
41: 
42: 
43:     public function result($testName, $result, $message)
44:     {
45:         $message = Tester\Dumper::removeColors(trim($message));
46:         $outputs = array(
47:             Runner::PASSED => "-- OK: $testName",
48:             Runner::SKIPPED => "-- Skipped: $testName\n   $message",
49:             Runner::FAILED => "-- FAILED: $testName" . str_replace("\n", "\n   ", "\n" . $message),
50:         );
51:         fputs($this->file, $outputs[$result] . "\n\n");
52:     }
53: 
54: 
55:     public function end()
56:     {
57:         $jobCount = $this->runner->getJobCount();
58:         $results = $this->runner->getResults();
59:         $count = array_sum($results);
60:         fputs($this->file,
61:             ($results[Runner::FAILED] ? 'FAILURES!' : 'OK')
62:             . " ($jobCount tests"
63:             . ($results[Runner::FAILED] ? ", {$results[Runner::FAILED]} failures" : '')
64:             . ($results[Runner::SKIPPED] ? ", {$results[Runner::SKIPPED]} skipped" : '')
65:             . ($jobCount !== $count ? ', ' . ($jobCount - $count) . ' not run' : '')
66:             . ')'
67:         );
68:     }
69: 
70: }
71: 
API documentation generated by ApiGen 2.8.0