Completed
Push — master ( 5d04a1...0cf74a )
by Vincenzo
02:49
created

Helpers::testRoundSimulator()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 20
Code Lines 14

Duplication

Lines 20
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 20
loc 20
rs 9.4285
cc 1
eloc 14
nc 1
nop 0
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 View Code Duplication
    public function testMatchSimulator()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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::simulate($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 View Code Duplication
    public function testRoundSimulator()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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
    }
77
78
}
79