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

WeaponTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 11
dl 0
loc 14
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A testIsRanged() 0 13 3
1
<?php
2
declare(strict_types=1);
3
4
namespace HeroesofAbenez\Combat;
5
6
use Tester\Assert;
7
8
require __DIR__ . "/../../bootstrap.php";
9
10
/**
11
 * @author Jakub Konečný
12
 * @testCase
13
 */
14
final class WeaponTest extends \Tester\TestCase {
15
  public function testIsRanged(): void {
16
    $weaponStats = [
17
      "id" => 1, "name" => "Weapon", "slot" => Equipment::SLOT_WEAPON, "strength" => 1, "worn" => true,
18
    ];
19
    foreach(Weapon::MELEE_TYPES as $meleeWeapon) {
20
      $weaponStats["type"] = $meleeWeapon;
21
      $weapon = new Weapon($weaponStats);
22
      Assert::false($weapon->ranged);
23
    }
24
    foreach(Weapon::RANGED_TYPES as $rangedWeapon) {
25
      $weaponStats["type"] = $rangedWeapon;
26
      $weapon = new Weapon($weaponStats);
27
      Assert::true($weapon->ranged);
28
    }
29
  }
30
}
31
32
$test = new WeaponTest();
33
$test->run();
34
?>