Completed
Push — 4-remove_support_for_phpt_file... ( fb372d...010fe9 )
by Jakub
01:43
created

TestsRunner   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 9
Bugs 0 Features 3
Metric Value
eloc 12
c 9
b 0
f 3
dl 0
loc 22
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A addSuit() 0 2 1
A execute() 0 10 3
1
<?php
2
declare(strict_types=1);
3
4
namespace MyTester\Bridges\NetteDI;
5
6
require_once __DIR__ . "/../../functions.php";
7
8
use MyTester\TestCase;
9
use MyTester\Environment;
10
11
/**
12
 * Tests Runner
13
 *
14
 * @author Jakub Konečný
15
 * @method void onExecute()
16
 * @internal
17
 */
18
final class TestsRunner {
19
  use \Nette\SmartObject;
20
21
  /** @var TestCase[] */
22
  private array $suits = [];
23
  /** @var callable[] */
24
  public array $onExecute = [];
25
  
26
  public function addSuit(TestCase $suit): void {
27
    $this->suits[] = $suit;
28
  }
29
  
30
  public function execute(): bool {
31
    $this->onExecute();
32
    $failed = false;
33
    foreach($this->suits as $suit) {
34
      if(!$suit->run()) {
35
        $failed = true;
36
      }
37
    }
38
    Environment::printResults();
39
    return $failed;
40
  }
41
}
42
?>