StaticSuccessCalculatorTest   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
eloc 14
c 1
b 0
f 0
dl 0
loc 32
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testHasHealed() 0 5 2
A generateCharacter() 0 7 1
A testHasHit() 0 6 2
A setUp() 0 3 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
{
16
    private StaticSuccessCalculator $calculator;
17
18
    protected function setUp(): void
19
    {
20
        $this->calculator = new StaticSuccessCalculator();
21
    }
22
23
    private function generateCharacter(int $id): Character
24
    {
25
        $stats = [
26
            "id" => $id, "name" => "Player $id", "level" => 1, "initiativeFormula" => "1d2+DEX/4", "strength" => 10,
27
            "dexterity" => 10, "constitution" => 10, "intelligence" => 10, "charisma" => 10
28
        ];
29
        return new Character($stats);
30
    }
31
32
    public function testHasHit(): void
33
    {
34
        $character1 = $this->generateCharacter(1);
35
        $character2 = $this->generateCharacter(2);
36
        for ($i = 1; $i <= 10; $i++) {
37
            Assert::true($this->calculator->hasHit($character1, $character2));
38
        }
39
    }
40
41
    public function testHasHealed(): void
42
    {
43
        $character1 = $this->generateCharacter(1);
44
        for ($i = 1; $i <= 10; $i++) {
45
            Assert::true($this->calculator->hasHealed($character1));
46
        }
47
    }
48
}
49
50
$test = new StaticSuccessCalculatorTest();
51
$test->run();
52