123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- <?php
- namespace Codeception\Extension;
- use Codeception\Event\FailEvent;
- use Codeception\Events;
- use Codeception\Extension;
- use Codeception\Subscriber\Console;
- class DotReporter extends Extension
- {
-
- protected $standardReporter;
- protected $errors = [];
- protected $failures = [];
- protected $width = 10;
- protected $currentPos = 0;
- public function _initialize()
- {
- $this->options['silent'] = false;
- $this->_reconfigure(['settings' => ['silent' => true]]);
- $this->standardReporter = new Console($this->options);
- $this->width = $this->standardReporter->detectWidth();
- }
-
- public static $events = [
- Events::SUITE_BEFORE => 'beforeSuite',
- Events::TEST_SUCCESS => 'success',
- Events::TEST_FAIL => 'fail',
- Events::TEST_ERROR => 'error',
- Events::TEST_SKIPPED => 'skipped',
- Events::TEST_FAIL_PRINT => 'printFailed'
- ];
- public function beforeSuite()
- {
- $this->writeln("");
- }
- public function success()
- {
- $this->printChar('.');
- }
- public function fail(FailEvent $e)
- {
- $this->printChar("<error>F</error>");
- }
- public function error(FailEvent $e)
- {
- $this->printChar('<error>E</error>');
- }
- public function skipped()
- {
- $this->printChar('S');
- }
-
- protected function printChar($char)
- {
- if ($this->currentPos >= $this->width) {
- $this->writeln('');
- $this->currentPos = 0;
- }
- $this->write($char);
- $this->currentPos++;
- }
- public function printFailed(FailEvent $event)
- {
- $this->standardReporter->printFail($event);
- }
- }
|