Passed
Push — master ( bc69e6...465240 )
by Jakub
12:35
created

StaticSuccessCalculatorTest   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 6
eloc 14
dl 0
loc 27
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testHasHealed() 0 4 2
A generateCharacter() 0 6 1
A testHasHit() 0 5 2
A setUp() 0 2 1
1
<?php
2
declare(strict_types=1);
3
4
namespace HeroesofAbenez\Combat;
5
6
require __DIR__ . "/../../bootstrap.php";
7
8
use Tester\Assert;
9
10
/**
11
 * @author Jakub Konečný
12
 * @testCase
13
 */
14
final class StaticSuccessCalculatorTest extends \Tester\TestCase {
15
  protected StaticSuccessCalculator $calculator;
16
  
17
  protected function setUp() {
18
    $this->calculator = new StaticSuccessCalculator();
19
  }
20
  
21
  protected function generateCharacter(int $id): Character {
22
    $stats = [
23
      "id" => $id, "name" => "Player $id", "level" => 1, "initiativeFormula" => "1d2+DEX/4", "strength" => 10,
24
      "dexterity" => 10, "constitution" => 10, "intelligence" => 10, "charisma" => 10
25
    ];
26
    return new Character($stats);
27
  }
28
  
29
  public function testHasHit(): void {
30
    $character1 = $this->generateCharacter(1);
31
    $character2 = $this->generateCharacter(2);
32
    for($i = 1; $i <= 10; $i++) {
33
      Assert::true($this->calculator->hasHit($character1, $character2));
34
    }
35
  }
36
  
37
  public function testHasHealed(): void {
38
    $character1 = $this->generateCharacter(1);
39
    for($i = 1; $i <= 10; $i++) {
40
      Assert::true($this->calculator->hasHealed($character1));
41
    }
42
  }
43
}
44
45
$test = new StaticSuccessCalculatorTest();
46
$test->run();
47
?>