WeaponTest::testIsRanged()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 14
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 14
rs 9.9332
cc 3
nc 4
nop 0
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
{
16
    public function testIsRanged(): void
17
    {
18
        $weaponStats = [
19
            "id" => 1, "name" => "Weapon", "slot" => Equipment::SLOT_WEAPON, "strength" => 1, "worn" => true,
20
        ];
21
        foreach (Weapon::MELEE_TYPES as $meleeWeapon) {
22
            $weaponStats["type"] = $meleeWeapon;
23
            $weapon = new Weapon($weaponStats);
24
            Assert::false($weapon->ranged);
25
        }
26
        foreach (Weapon::RANGED_TYPES as $rangedWeapon) {
27
            $weaponStats["type"] = $rangedWeapon;
28
            $weapon = new Weapon($weaponStats);
29
            Assert::true($weapon->ranged);
30
        }
31
    }
32
}
33
34
$test = new WeaponTest();
35
$test->run();
36