ModuleConfigurationTest::testRandomFiller()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 3
Metric Value
c 3
b 0
f 3
dl 0
loc 7
rs 9.4285
cc 2
eloc 4
nc 2
nop 0
1
<?php
2
3
4
/**
5
 * Class ModuleConfigurationTest
6
 */
7
class ModuleConfigurationTest extends \PHPUnit_Framework_TestCase
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
8
{
9
10
11
    /**
12
     * @group Modules
13
     * @group config
14
     */
15
    public function testAllTheModulesGot11Players()
16
    {
17
        $modules = \App\Lib\Helpers\Config::get('modules.modules');
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $modules is correct as \App\Lib\Helpers\Config::get('modules.modules') (which targets App\Lib\Helpers\Config::get()) seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
18
        $this->assertNotEmpty($modules);
19
        foreach ($modules as $key => $module) {
0 ignored issues
show
Bug introduced by
The expression $modules of type null is not traversable.
Loading history...
20
            $this->assertNotEmpty($module["roles"]);
21
            $count = 0;
22
            foreach ($module["roles"] as $roleNum) {
23
                $count += $roleNum;
24
            }
25
            $this->assertTrue(11 === $count, "Not correct Players for $key");
26
        }
27
    }
28
29
    /**
30
     * @group Roles
31
     * @group config
32
     */
33
    public function testCorrectDisplayModuleDescriptionRole()
34
    {
35
        $modules = \App\Lib\Helpers\Config::get('modules.modules');
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $modules is correct as \App\Lib\Helpers\Config::get('modules.modules') (which targets App\Lib\Helpers\Config::get()) seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
36
        $this->assertNotEmpty($modules);
37
        $roles = \App\Lib\Helpers\Config::get('modules.roles');
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $roles is correct as \App\Lib\Helpers\Config::get('modules.roles') (which targets App\Lib\Helpers\Config::get()) seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
38
        $rolesKeys = array_keys($roles);
39
40
        foreach ($modules as $key => $module) {
0 ignored issues
show
Bug introduced by
The expression $modules of type null is not traversable.
Loading history...
41
            $this->assertNotEmpty($module["roles"]);
42
            foreach ($module["roles"] as $index => $playNum) {
43
                if ($playNum != 0) {
44
                    $this->assertGreaterThan(0, $playNum);
45
                    $this->assertNotNull($roles[$rolesKeys[$index]]["description"]);
46
                }
47
            }
48
        }
49
    }
50
51
    /**
52
     * @group rand
53
     *
54
     */
55
    public function testRandomizer()
56
    {
57
        $yes = 0;
58
        $no = 0;
59
        for ($i = 1; $i <= 100; $i++) {
60
            if (\App\Lib\DsManager\Helpers\Randomizer::boolOnPercentage(20)) {
61
                $yes++;
62
            } else {
63
                $no++;
64
            }
65
        }
66
        $this->assertNotEmpty($yes);
67
        $this->assertNotEmpty($no);
68
        $this->assertGreaterThan($yes, $no);
69
    }
70
71
    /**
72
     * @group randFiller
73
     *
74
     */
75
    public function testRandomFiller()
76
    {
77
        $rndF = new \App\Lib\DsManager\Helpers\RandomFiller();
78
        for ($i = 1; $i <= 10; $i++) {
79
            $this->assertNotEmpty($rndF->getLocale());
80
        }
81
    }
82
83
}
84