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

TestsRunner::autoload()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 5
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 4
nc 3
nop 1
dl 0
loc 5
rs 10
c 0
b 0
f 0
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
?>