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

CharacterAttackSkillTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 31
dl 0
loc 45
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testGetDamage() 0 10 1
A testGetLevel() 0 8 1
A testGetSkillType() 0 8 1
A testGetHitRate() 0 12 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 CharacterAttackSkillTest extends \Tester\TestCase {
15
  public function testGetSkillType(): void {
16
    $skillData = [
17
      "id" => 1, "name" => "Skill Attack", "baseDamage" => "120%", "damageGrowth" => "2%", "levels" => 5,
18
      "target" => SkillAttack::TARGET_SINGLE, "strikes" => 1, "hitRate" => "100%",
19
    ];
20
    $skill = new SkillAttack($skillData);
21
    $characterSkill = new CharacterAttackSkill($skill, 1);
22
    Assert::same("attack", $characterSkill->skillType);
23
  }
24
  
25
  public function testGetLevel(): void {
26
    $skillData = [
27
      "id" => 1, "name" => "Skill Attack", "baseDamage" => "120%", "damageGrowth" => "2%", "levels" => 5,
28
      "target" => SkillAttack::TARGET_SINGLE, "strikes" => 1, "hitRate" => "100%",
29
    ];
30
    $skill = new SkillAttack($skillData);
31
    $characterSkill = new CharacterAttackSkill($skill, 1);
32
    Assert::same(1, $characterSkill->level);
33
  }
34
  
35
  public function testGetDamage(): void {
36
    $skillData = [
37
      "id" => 1, "name" => "Skill Attack", "baseDamage" => "120%", "damageGrowth" => "2%", "levels" => 5,
38
      "target" => SkillAttack::TARGET_SINGLE, "strikes" => 1, "hitRate" => "100%",
39
    ];
40
    $skill = new SkillAttack($skillData);
41
    $characterSkill = new CharacterAttackSkill($skill, 1);
42
    Assert::same(120, $characterSkill->damage);
43
    $characterSkill = new CharacterAttackSkill($skill, 5);
44
    Assert::same(128, $characterSkill->damage);
45
  }
46
  
47
  public function testGetHitRate(): void {
48
    $skillData = [
49
      "id" => 1, "name" => "Skill Attack", "baseDamage" => "120%", "damageGrowth" => "2%", "levels" => 5,
50
      "target" => SkillAttack::TARGET_SINGLE, "strikes" => 1, "hitRate" => null,
51
    ];
52
    $skill = new SkillAttack($skillData);
53
    $characterSkill = new CharacterAttackSkill($skill, 1);
54
    Assert::same(100, $characterSkill->hitRate);
55
    $skillData["hitRate"] = "80%";
56
    $skill = new SkillAttack($skillData);
57
    $characterSkill = new CharacterAttackSkill($skill, 1);
58
    Assert::same(80, $characterSkill->hitRate);
59
  }
60
}
61
62
$test = new CharacterAttackSkillTest();
63
$test->run();
64
?>