Helpers   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 75
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 2
Bugs 1 Features 2
Metric Value
wmc 4
c 2
b 1
f 2
lcom 1
cbo 4
dl 0
loc 75
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testFixtureGenerator() 0 13 2
A testMatchSimulator() 0 18 1
A testRoundSimulator() 0 23 1
1
<?php
2
3
4
/**
5
 * Class Helpers
6
 */
7
class Helpers 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 Helpers
13
     * @group FixtureGenerator
14
     * @group generatefixture
15
     */
16
    public function testFixtureGenerator()
17
    {
18
        $teams = \App\Lib\DsManager\Models\Orm\Team::all();
19
        $rounds = \App\Lib\DsManager\Helpers\LeagueFixtureGenerator::generate(
20
            $teams->toArray()
21
        );
22
        //Number of rounds
23
        $this->assertCount($teams->count() - 1, $rounds);
24
        //Matches for each round
25
        foreach ($rounds as $round) {
26
            $this->assertCount($teams->count() / 2, $round);
27
        }
28
    }
29
30
    /**
31
     * @group Helpers
32
     * @group MatchSimulator
33
     */
34
    public function testMatchSimulator()
35
    {
36
        $match = \App\Lib\DsManager\Models\Orm\Match::where(
37
            [
38
                'simulated' => false
39
            ]
40
        )->get()->random(1);
41
        $this->assertNotEmpty($match);
42
        $result = \App\Lib\DsManager\Helpers\MatchSimulator::simulateCompleteResult($match->id);
43
        $this->assertNotEmpty($result);
44
        $match = \App\Lib\DsManager\Models\Orm\Match::where(
45
            [
46
                'id' => $match->id,
47
                'simulated' => true
48
            ]
49
        )->first();
50
        $this->assertNotEmpty($match);
51
    }
52
53
    /**
54
     * @group Helpers
55
     * @group RoundSimulator
56
     */
57
    public function testRoundSimulator()
58
    {
59
        $match = \App\Lib\DsManager\Models\Orm\Match::where(
60
            [
61
                'simulated' => false
62
            ]
63
        )->whereNotNull(
64
            'league_round_id'
65
        )->get()->random(1);
66
        $this->assertNotEmpty($match);
67
        $result = \App\Lib\DsManager\Helpers\MatchSimulator::simulateRound($match->league_round_id);
68
        $this->assertNotEmpty($result);
69
        $match = \App\Lib\DsManager\Models\Orm\Match::where(
70
            [
71
                'id' => $match->id,
72
                'simulated' => true
73
            ]
74
        )->first();
75
        $this->assertNotEmpty($match);
76
        $round = \App\Lib\DsManager\Models\Orm\LeagueRound::find($match->league_round_id);
77
        $this->assertNotEmpty($round);
78
        $this->assertTrue($round->simulated);
79
    }
80
81
}
82