Completed
Push — master ( b65b7b...c616f0 )
by Vincenzo
02:30
created
api/tests/OrmModelsTest.php 1 patch
Indentation   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -8,70 +8,70 @@
 block discarded – undo
8 8
 {
9 9
 
10 10
 
11
-    /**
12
-     * @group OrmModels
13
-     * @group PlayerOrm
14
-     */
15
-    public function testPlayerOrmGetSet()
16
-    {
17
-        $rndFiller = new \App\Lib\DsManager\Helpers\RandomFiller();
18
-        $playerM = $rndFiller->getPlayer();
19
-        $arrayPl = $playerM->toArray();
20
-        $playerO = \App\Lib\DsManager\Models\Orm\Player::create($arrayPl);
21
-        $this->assertNotEmpty($playerO);
11
+	/**
12
+	 * @group OrmModels
13
+	 * @group PlayerOrm
14
+	 */
15
+	public function testPlayerOrmGetSet()
16
+	{
17
+		$rndFiller = new \App\Lib\DsManager\Helpers\RandomFiller();
18
+		$playerM = $rndFiller->getPlayer();
19
+		$arrayPl = $playerM->toArray();
20
+		$playerO = \App\Lib\DsManager\Models\Orm\Player::create($arrayPl);
21
+		$this->assertNotEmpty($playerO);
22 22
 
23
-        $newPlayer = \App\Lib\DsManager\Models\Player::fromArray($playerO->toArray());
24
-        $this->assertNotEmpty($newPlayer);
25
-    }
23
+		$newPlayer = \App\Lib\DsManager\Models\Player::fromArray($playerO->toArray());
24
+		$this->assertNotEmpty($newPlayer);
25
+	}
26 26
 
27
-    /**
28
-     * @group OrmModels
29
-     * @group CoachOrm
30
-     */
31
-    public function testCoachOrmGetSet()
32
-    {
33
-        $rndFiller = new \App\Lib\DsManager\Helpers\RandomFiller();
34
-        $coach = $rndFiller->getCoach();
35
-        $arrayPl = $coach->toArray();
36
-        $coachO = \App\Lib\DsManager\Models\Orm\Coach::create($arrayPl);
37
-        $this->assertNotEmpty($coachO);
27
+	/**
28
+	 * @group OrmModels
29
+	 * @group CoachOrm
30
+	 */
31
+	public function testCoachOrmGetSet()
32
+	{
33
+		$rndFiller = new \App\Lib\DsManager\Helpers\RandomFiller();
34
+		$coach = $rndFiller->getCoach();
35
+		$arrayPl = $coach->toArray();
36
+		$coachO = \App\Lib\DsManager\Models\Orm\Coach::create($arrayPl);
37
+		$this->assertNotEmpty($coachO);
38 38
 
39
-        $newCoach = \App\Lib\DsManager\Models\Coach::fromArray($coachO->toArray());
40
-        $this->assertNotEmpty($newCoach);
41
-    }
39
+		$newCoach = \App\Lib\DsManager\Models\Coach::fromArray($coachO->toArray());
40
+		$this->assertNotEmpty($newCoach);
41
+	}
42 42
 
43
-    /**
44
-     * @group OrmModels
45
-     * @group TeamOrm
46
-     */
47
-    public function testTeamOrm()
48
-    {
49
-        $rndFiller = new \App\Lib\DsManager\Helpers\RandomFiller();
50
-        $team = $rndFiller->getTeam($rndFiller->getLocale());
51
-        $teamArray = $team->toArray();
52
-        $this->assertNotEmpty($team);
53
-        $teamO = \App\Lib\DsManager\Models\Orm\Team::create($teamArray);
54
-        $this->assertNotEmpty($teamArray);
55
-        $this->assertNotEmpty($teamArray['roster']);
56
-        foreach ($teamArray['roster'] as $player) {
57
-            $player['team_id'] = $teamO->id;
58
-            $playerO = \App\Lib\DsManager\Models\Orm\Player::create($player);
59
-            $this->assertNotEmpty($playerO);
60
-        }
61
-        $teamArray['coach']['team_id'] = $teamO->id;
62
-        $coachO = \App\Lib\DsManager\Models\Orm\Coach::create($teamArray['coach']);
63
-        $this->assertNotEmpty($coachO);
43
+	/**
44
+	 * @group OrmModels
45
+	 * @group TeamOrm
46
+	 */
47
+	public function testTeamOrm()
48
+	{
49
+		$rndFiller = new \App\Lib\DsManager\Helpers\RandomFiller();
50
+		$team = $rndFiller->getTeam($rndFiller->getLocale());
51
+		$teamArray = $team->toArray();
52
+		$this->assertNotEmpty($team);
53
+		$teamO = \App\Lib\DsManager\Models\Orm\Team::create($teamArray);
54
+		$this->assertNotEmpty($teamArray);
55
+		$this->assertNotEmpty($teamArray['roster']);
56
+		foreach ($teamArray['roster'] as $player) {
57
+			$player['team_id'] = $teamO->id;
58
+			$playerO = \App\Lib\DsManager\Models\Orm\Player::create($player);
59
+			$this->assertNotEmpty($playerO);
60
+		}
61
+		$teamArray['coach']['team_id'] = $teamO->id;
62
+		$coachO = \App\Lib\DsManager\Models\Orm\Coach::create($teamArray['coach']);
63
+		$this->assertNotEmpty($coachO);
64 64
 
65
-        $this->assertNotEmpty(
66
-            \App\Lib\DsManager\Models\Orm\Team::with(
67
-                'roster'
68
-            )->with(
69
-                'coach'
70
-            )->where(
71
-                [
72
-                    'id' => $teamO->id
73
-                ]
74
-            )->get()->toArray()
75
-        );
76
-    }
65
+		$this->assertNotEmpty(
66
+			\App\Lib\DsManager\Models\Orm\Team::with(
67
+				'roster'
68
+			)->with(
69
+				'coach'
70
+			)->where(
71
+				[
72
+					'id' => $teamO->id
73
+				]
74
+			)->get()->toArray()
75
+		);
76
+	}
77 77
 }
Please login to merge, or discard this patch.
api/tests/ModuleConfigurationTest.php 1 patch
Indentation   +67 added lines, -67 removed lines patch added patch discarded remove patch
@@ -8,76 +8,76 @@
 block discarded – undo
8 8
 {
9 9
 
10 10
 
11
-    /**
12
-     * @group Modules
13
-     * @group config
14
-     */
15
-    public function testAllTheModulesGot11Players()
16
-    {
17
-        $modules = \App\Lib\Helpers\Config::get('modules.modules');
18
-        $this->assertNotEmpty($modules);
19
-        foreach ($modules as $key => $module) {
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
-    }
11
+	/**
12
+	 * @group Modules
13
+	 * @group config
14
+	 */
15
+	public function testAllTheModulesGot11Players()
16
+	{
17
+		$modules = \App\Lib\Helpers\Config::get('modules.modules');
18
+		$this->assertNotEmpty($modules);
19
+		foreach ($modules as $key => $module) {
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 28
 
29
-    /**
30
-     * @group Roles
31
-     * @group config
32
-     */
33
-    public function testCorrectDisplayModuleDescriptionRole()
34
-    {
35
-        $modules = \App\Lib\Helpers\Config::get('modules.modules');
36
-        $this->assertNotEmpty($modules);
37
-        $roles = \App\Lib\Helpers\Config::get('modules.roles');
38
-        $rolesKeys = array_keys($roles);
29
+	/**
30
+	 * @group Roles
31
+	 * @group config
32
+	 */
33
+	public function testCorrectDisplayModuleDescriptionRole()
34
+	{
35
+		$modules = \App\Lib\Helpers\Config::get('modules.modules');
36
+		$this->assertNotEmpty($modules);
37
+		$roles = \App\Lib\Helpers\Config::get('modules.roles');
38
+		$rolesKeys = array_keys($roles);
39 39
 
40
-        foreach ($modules as $key => $module) {
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
-    }
40
+		foreach ($modules as $key => $module) {
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 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
-    }
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 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
-    }
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 82
 
83 83
 }
Please login to merge, or discard this patch.
api/database/seeds/ATeamsSeeder.php 1 patch
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -3,20 +3,20 @@
 block discarded – undo
3 3
 
4 4
 class ATeamsSeeder
5 5
 {
6
-    function run()
7
-    {
8
-        $teamNumber = 10;
9
-        $rndFiller = new \App\Lib\DsManager\Helpers\RandomFiller();
10
-        for ($i = 1; $i <= $teamNumber; $i++) {
11
-            $team = $rndFiller->getTeam($rndFiller->getLocale());
12
-            $teamArray = $team->toArray();
13
-            $teamO = \App\Lib\DsManager\Models\Orm\Team::create($teamArray);
14
-            foreach ($teamArray['roster'] as $player) {
15
-                $player['team_id'] = $teamO->id;
16
-                \App\Lib\DsManager\Models\Orm\Player::create($player);
17
-            }
18
-            $teamArray['coach']['team_id'] = $teamO->id;
19
-            \App\Lib\DsManager\Models\Orm\Coach::create($teamArray['coach']);
20
-        }
21
-    }
6
+	function run()
7
+	{
8
+		$teamNumber = 10;
9
+		$rndFiller = new \App\Lib\DsManager\Helpers\RandomFiller();
10
+		for ($i = 1; $i <= $teamNumber; $i++) {
11
+			$team = $rndFiller->getTeam($rndFiller->getLocale());
12
+			$teamArray = $team->toArray();
13
+			$teamO = \App\Lib\DsManager\Models\Orm\Team::create($teamArray);
14
+			foreach ($teamArray['roster'] as $player) {
15
+				$player['team_id'] = $teamO->id;
16
+				\App\Lib\DsManager\Models\Orm\Player::create($player);
17
+			}
18
+			$teamArray['coach']['team_id'] = $teamO->id;
19
+			\App\Lib\DsManager\Models\Orm\Coach::create($teamArray['coach']);
20
+		}
21
+	}
22 22
 }
23 23
\ No newline at end of file
Please login to merge, or discard this patch.
api/database/migrations/CreateTeamTable.php 1 patch
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -5,19 +5,19 @@
 block discarded – undo
5 5
 
6 6
 class CreateTeamTable
7 7
 {
8
-    /**
9
-     * Run the migrations.
10
-     *
11
-     * @return void
12
-     */
13
-    public function run()
14
-    {
15
-        Capsule::schema()->dropIfExists('teams');
16
-        Capsule::schema()->create('teams', function (Blueprint $table) {
17
-            $table->increments('id');
18
-            $table->string('name');
19
-            $table->string('nationality',2);
20
-            $table->timestamps();
21
-        });
22
-    }
8
+	/**
9
+	 * Run the migrations.
10
+	 *
11
+	 * @return void
12
+	 */
13
+	public function run()
14
+	{
15
+		Capsule::schema()->dropIfExists('teams');
16
+		Capsule::schema()->create('teams', function (Blueprint $table) {
17
+			$table->increments('id');
18
+			$table->string('name');
19
+			$table->string('nationality',2);
20
+			$table->timestamps();
21
+		});
22
+	}
23 23
 }
Please login to merge, or discard this patch.
api/database/migrations/CreateCoachesTable.php 1 patch
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -5,35 +5,35 @@
 block discarded – undo
5 5
 
6 6
 class CreateCoachesTable
7 7
 {
8
-    /**
9
-     * Run the migrations.
10
-     *
11
-     * @return void
12
-     */
13
-    public function run()
14
-    {
15
-        Capsule::schema()->dropIfExists('coaches');
16
-        Capsule::schema()->create('coaches', function (Blueprint $table) {
17
-            $table->increments('id');
18
-            $table->string('name');
19
-            $table->string('surname');
20
-            $table->tinyInteger('age');
21
-            $table->string('nationality',2);
22
-            $table->float('skillAvg');
23
-            $table->float('wageReq');
24
-            $table->string('favouriteModule',10);
25
-            $table->integer('team_id')->nullable();
26
-            $table->timestamps();
27
-        });
28
-    }
8
+	/**
9
+	 * Run the migrations.
10
+	 *
11
+	 * @return void
12
+	 */
13
+	public function run()
14
+	{
15
+		Capsule::schema()->dropIfExists('coaches');
16
+		Capsule::schema()->create('coaches', function (Blueprint $table) {
17
+			$table->increments('id');
18
+			$table->string('name');
19
+			$table->string('surname');
20
+			$table->tinyInteger('age');
21
+			$table->string('nationality',2);
22
+			$table->float('skillAvg');
23
+			$table->float('wageReq');
24
+			$table->string('favouriteModule',10);
25
+			$table->integer('team_id')->nullable();
26
+			$table->timestamps();
27
+		});
28
+	}
29 29
 
30
-    /**
31
-     * Reverse the migrations.
32
-     *
33
-     * @return void
34
-     */
35
-    public function down()
36
-    {
37
-        Schema::drop('coaches');
38
-    }
30
+	/**
31
+	 * Reverse the migrations.
32
+	 *
33
+	 * @return void
34
+	 */
35
+	public function down()
36
+	{
37
+		Schema::drop('coaches');
38
+	}
39 39
 }
Please login to merge, or discard this patch.
api/database/migrations/CreatePlayersTable.php 1 patch
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -5,26 +5,26 @@
 block discarded – undo
5 5
 
6 6
 class CreatePlayersTable
7 7
 {
8
-    /**
9
-     * Run the migrations.
10
-     *
11
-     * @return void
12
-     */
13
-    public function run()
14
-    {
15
-        Capsule::schema()->dropIfExists('players');
16
-        Capsule::schema()->create('players', function (Blueprint $table) {
17
-            $table->increments('id');
18
-            $table->string('name');
19
-            $table->string('surname');
20
-            $table->tinyInteger('age');
21
-            $table->string('nationality',2);
22
-            $table->float('skillAvg');
23
-            $table->float('wageReq');
24
-            $table->float('val');
25
-            $table->string('role',2);
26
-            $table->integer('team_id')->nullable();
27
-            $table->timestamps();
28
-        });
29
-    }
8
+	/**
9
+	 * Run the migrations.
10
+	 *
11
+	 * @return void
12
+	 */
13
+	public function run()
14
+	{
15
+		Capsule::schema()->dropIfExists('players');
16
+		Capsule::schema()->create('players', function (Blueprint $table) {
17
+			$table->increments('id');
18
+			$table->string('name');
19
+			$table->string('surname');
20
+			$table->tinyInteger('age');
21
+			$table->string('nationality',2);
22
+			$table->float('skillAvg');
23
+			$table->float('wageReq');
24
+			$table->float('val');
25
+			$table->string('role',2);
26
+			$table->integer('team_id')->nullable();
27
+			$table->timestamps();
28
+		});
29
+	}
30 30
 }
Please login to merge, or discard this patch.
api/config/config.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -4,9 +4,9 @@  discard block
 block discarded – undo
4 4
 
5 5
 $dotenv = new Dotenv\Dotenv(__DIR__ . "/../");
6 6
 try {
7
-    $dotenv->load();
7
+	$dotenv->load();
8 8
 } catch (Exception $e) {
9
-    //yummy exception
9
+	//yummy exception
10 10
 }
11 11
 
12 12
 /**
@@ -14,14 +14,14 @@  discard block
 block discarded – undo
14 14
  */
15 15
 $capsule = new Capsule;
16 16
 $capsule->addConnection(array(
17
-    'driver' => 'mysql',
18
-    'host' => 'localhost',
19
-    'database' => 'dsmanager',
20
-    'username' => getenv('USERNAME'),
21
-    'password' => getenv('PASSWORD'),
22
-    'charset' => 'utf8',
23
-    'collation' => 'utf8_general_ci',
24
-    'prefix' => ''
17
+	'driver' => 'mysql',
18
+	'host' => 'localhost',
19
+	'database' => 'dsmanager',
20
+	'username' => getenv('USERNAME'),
21
+	'password' => getenv('PASSWORD'),
22
+	'charset' => 'utf8',
23
+	'collation' => 'utf8_general_ci',
24
+	'prefix' => ''
25 25
 ));
26 26
 $capsule->setAsGlobal();
27 27
 $capsule->bootEloquent();
Please login to merge, or discard this patch.
api/tests/ModelsTest.php 1 patch
Indentation   +217 added lines, -217 removed lines patch added patch discarded remove patch
@@ -8,222 +8,222 @@
 block discarded – undo
8 8
 {
9 9
 
10 10
 
11
-    /**
12
-     * @group Player
13
-     */
14
-    public function testGetRandomPlayer()
15
-    {
16
-        $rndF = new \App\Lib\DsManager\Helpers\RandomFiller();
17
-        $player = $rndF->getPlayer(null, $rndF->getLocale());
18
-        $array = $player->toArray();
19
-        $this->assertNotEmpty($array);
20
-
21
-        $newPlayer = \App\Lib\DsManager\Models\Player::fromArray($array);
22
-        $this->assertNotEmpty($newPlayer->toArray());
23
-    }
24
-
25
-    /**
26
-     * @group Coach
27
-     */
28
-    public function testGetRandomCoach()
29
-    {
30
-        $rndF = new \App\Lib\DsManager\Helpers\RandomFiller();
31
-        $coach = $rndF->getCoach();
32
-        $this->assertNotEmpty($coach->toArray());
33
-    }
34
-
35
-    /**
36
-     * @group Coaches
37
-     */
38
-    public function testGetRandomCoaches()
39
-    {
40
-        foreach (\App\Lib\Helpers\Config::get('generic.localesSmall') as $nat) {
41
-            $rndF = new \App\Lib\DsManager\Helpers\RandomFiller($nat);
42
-            $coach = $rndF->getCoach();
43
-            $this->assertNotEmpty($coach->toArray());
44
-        }
45
-    }
46
-
47
-    /**
48
-     * @group Players
49
-     */
50
-    public function testGetRandomPlayers()
51
-    {
52
-        foreach (\App\Lib\Helpers\Config::get('generic.localesSmall') as $nat) {
53
-            $rndF = new \App\Lib\DsManager\Helpers\RandomFiller($nat);
54
-            $player = $rndF->getPlayer();
55
-            $this->assertNotEmpty($player->toArray());
56
-        }
57
-    }
58
-
59
-    /**
60
-     * @group Team
61
-     */
62
-    public function testGetRandomTeam()
63
-    {
64
-        $rndF = new \App\Lib\DsManager\Helpers\RandomFiller("it_IT");
65
-        $team = $rndF->getTeam();
66
-        $this->assertNotEmpty($team);
67
-        $this->assertNotEmpty($team->name);
68
-        $this->assertNotEmpty($team->getAvgSkill());
69
-
70
-        //After Adding a player
71
-        $player = $rndF->getPlayer();
72
-        $this->assertNotEmpty($player->toArray());
73
-        $team->roster[] = $player;
74
-        $this->assertNotEmpty($team->getAvgSkill());
75
-        $this->assertNotEmpty($team->getAvgAge());
76
-
77
-        $this->assertNotEmpty($team->coach->toArray());
78
-
79
-        $teamArray = $team->toArray();
80
-        $this->assertNotEmpty($teamArray);
81
-
82
-        $newTeam = \App\Lib\DsManager\Models\Team::fromArray($teamArray);
83
-        $this->assertNotEmpty($newTeam->toArray());
84
-
85
-    }
86
-
87
-    /**
88
-     * @group Teams
89
-     */
90
-    public function testGetRandomTeams()
91
-    {
92
-        $rndF = new \App\Lib\DsManager\Helpers\RandomFiller("it_IT");
93
-
94
-        for ($i = 1; $i <= 20; $i++) {
95
-            $team = $rndF->getTeam();
96
-            $this->assertNotEmpty($team->name);
97
-            $this->assertNotEmpty($team->nationality);
98
-            $this->assertNotEmpty($team->getAvgSkill());
99
-            $this->assertNotEmpty($team->getAvgAge());
100
-        }
101
-    }
102
-
103
-    /**
104
-     * @group Match
105
-     */
106
-    public function testGetRandomMatch()
107
-    {
108
-        for ($i = 1; $i <= 30; $i++) {
109
-            $rndF = new \App\Lib\DsManager\Helpers\RandomFiller("it_IT");
110
-            $spanish = $rndF->getTeam();
111
-            $rndF = new \App\Lib\DsManager\Helpers\RandomFiller("it_IT");
112
-            $italian = $rndF->getTeam();
113
-            $this->assertNotEmpty($spanish);
114
-            $this->assertNotEmpty($italian);
115
-            $this->assertNotEmpty($italian->name);
116
-            $this->assertNotEmpty($spanish);
117
-            $this->assertNotEmpty($spanish->name);
118
-
119
-            $this->assertNotEmpty($italian->getAvgSkill());
120
-            $this->assertNotEmpty($spanish->getAvgSkill());
121
-            $result = (new \App\Lib\DsManager\Models\Match($italian, $spanish))->simulate()->toArray();
122
-            $this->assertNotEmpty($result);
123
-            $this->assertGreaterThanOrEqual(0, $result['goalHome']);
124
-            $this->assertGreaterThanOrEqual(0, $result['goalAway']);
125
-
126
-        }
127
-    }
128
-
129
-    /**
130
-     * @group Match
131
-     * @group MatchResult
132
-     * @group matchresultoutput
133
-     */
134
-    public function testMatchFromExistingTeams()
135
-    {
136
-        $teamHome = 1;
137
-        $teamAway = 2;
138
-        $homeOrm = \App\Lib\DsManager\Models\Orm\Team::with('roster', 'coach')->where(['id' => $teamHome])->first();
139
-        $awayOrm = \App\Lib\DsManager\Models\Orm\Team::with('roster', 'coach')->where(['id' => $teamAway])->first();
140
-        $home = \App\Lib\DsManager\Models\Team::fromArray($homeOrm->toArray());
141
-        $away = \App\Lib\DsManager\Models\Team::fromArray($awayOrm->toArray());
142
-
143
-        $match = new \App\Lib\DsManager\Models\Match($home, $away);
144
-        $result = $match->simulate()->toArray();
145
-        $this->assertNotEmpty($result);
146
-        $this->assertGreaterThanOrEqual(0, $result['goalAway']);
147
-        $this->assertGreaterThanOrEqual(0, $result['goalHome']);
148
-        if ($result['goalHome'] > 0) {
149
-            $this->assertNotEmpty($result['info']['scorers']['home']);
150
-            foreach ($result['info']['scorers']['home'] as $scorerHome) {
151
-                $this->assertEquals($scorerHome->team_id, $teamHome);
152
-            }
153
-        } else {
154
-            $this->assertEmpty($result['info']['scorers']['home']);
155
-        }
156
-        if ($result['goalAway'] > 0) {
157
-            $this->assertNotEmpty($result['info']['scorers']['away']);
158
-            foreach ($result['info']['scorers']['away'] as $scorerAway) {
159
-                $this->assertEquals($scorerAway->team_id, $teamAway);
160
-            }
161
-        } else {
162
-            $this->assertEmpty($result['info']['scorers']['away']);
163
-        }
164
-        if ($result['goalHome'] == $result['goalAway']) {
165
-            $this->assertTrue($result['info']['isDraw']);
166
-        } else {
167
-            $this->assertFalse($result['info']['isDraw']);
168
-        }
169
-    }
170
-
171
-    /**
172
-     * @group Matches
173
-     */
174
-    public function testGetRandomMatchesOneTeam()
175
-    {
176
-        $rndF = new \App\Lib\DsManager\Helpers\RandomFiller("it_IT");
177
-        $myTeam = $rndF->getTeam();
178
-        $win = 0;
179
-        $lost = 0;
180
-        $draw = 0;
181
-
182
-        for ($i = 1; $i <= 2; $i++) {
183
-
184
-            $randomLocale = \App\Lib\Helpers\Config::get('generic.localesSmall');
185
-            shuffle($randomLocale);
186
-            $randomLocale = $randomLocale[0];
187
-
188
-            $rndF = new \App\Lib\DsManager\Helpers\RandomFiller($randomLocale);
189
-            $opponent = $rndF->getTeam();
190
-            $result = (new \App\Lib\DsManager\Models\Match($opponent, $myTeam))->simulate()->toArray();
191
-            $this->assertNotEmpty($result);
192
-            $result = $result['info'];
193
-            if (!$result['isDraw']) {
194
-                if ($result['winner']['name'] == $myTeam->name) {
195
-                    $win++;
196
-                } else {
197
-                    $lost++;
198
-                }
199
-            } else {
200
-                $draw++;
201
-            }
202
-        }
203
-        $this->assertGreaterThanOrEqual(0, $win);
204
-        $this->assertGreaterThanOrEqual(0, $lost);
205
-        $this->assertGreaterThanOrEqual(0, $draw);
206
-    }
207
-
208
-    /**
209
-     * @group Module
210
-     */
211
-    public function testModule()
212
-    {
213
-        $rndF = new \App\Lib\DsManager\Helpers\RandomFiller("it_IT");
214
-        $team = $rndF->getTeam();
215
-
216
-        $modules = \App\Lib\Helpers\Config::get("modules.modules");
217
-        $modules = array_keys($modules);
218
-        foreach ($modules as $mod) {
219
-            $module = new \App\Lib\DsManager\Models\Module($mod);
220
-            $this->assertNotEmpty($module);
221
-            $this->assertNotNull($module->isDefensive());
222
-            $this->assertNotNull($module->isBalanced());
223
-            $this->assertNotNull($module->isOffensive());
224
-            $this->assertTrue(is_array($module->getRoleNeeded()));
225
-        }
226
-        $this->assertGreaterThan(0, $team->playersPerRoleArray());
227
-    }
11
+	/**
12
+	 * @group Player
13
+	 */
14
+	public function testGetRandomPlayer()
15
+	{
16
+		$rndF = new \App\Lib\DsManager\Helpers\RandomFiller();
17
+		$player = $rndF->getPlayer(null, $rndF->getLocale());
18
+		$array = $player->toArray();
19
+		$this->assertNotEmpty($array);
20
+
21
+		$newPlayer = \App\Lib\DsManager\Models\Player::fromArray($array);
22
+		$this->assertNotEmpty($newPlayer->toArray());
23
+	}
24
+
25
+	/**
26
+	 * @group Coach
27
+	 */
28
+	public function testGetRandomCoach()
29
+	{
30
+		$rndF = new \App\Lib\DsManager\Helpers\RandomFiller();
31
+		$coach = $rndF->getCoach();
32
+		$this->assertNotEmpty($coach->toArray());
33
+	}
34
+
35
+	/**
36
+	 * @group Coaches
37
+	 */
38
+	public function testGetRandomCoaches()
39
+	{
40
+		foreach (\App\Lib\Helpers\Config::get('generic.localesSmall') as $nat) {
41
+			$rndF = new \App\Lib\DsManager\Helpers\RandomFiller($nat);
42
+			$coach = $rndF->getCoach();
43
+			$this->assertNotEmpty($coach->toArray());
44
+		}
45
+	}
46
+
47
+	/**
48
+	 * @group Players
49
+	 */
50
+	public function testGetRandomPlayers()
51
+	{
52
+		foreach (\App\Lib\Helpers\Config::get('generic.localesSmall') as $nat) {
53
+			$rndF = new \App\Lib\DsManager\Helpers\RandomFiller($nat);
54
+			$player = $rndF->getPlayer();
55
+			$this->assertNotEmpty($player->toArray());
56
+		}
57
+	}
58
+
59
+	/**
60
+	 * @group Team
61
+	 */
62
+	public function testGetRandomTeam()
63
+	{
64
+		$rndF = new \App\Lib\DsManager\Helpers\RandomFiller("it_IT");
65
+		$team = $rndF->getTeam();
66
+		$this->assertNotEmpty($team);
67
+		$this->assertNotEmpty($team->name);
68
+		$this->assertNotEmpty($team->getAvgSkill());
69
+
70
+		//After Adding a player
71
+		$player = $rndF->getPlayer();
72
+		$this->assertNotEmpty($player->toArray());
73
+		$team->roster[] = $player;
74
+		$this->assertNotEmpty($team->getAvgSkill());
75
+		$this->assertNotEmpty($team->getAvgAge());
76
+
77
+		$this->assertNotEmpty($team->coach->toArray());
78
+
79
+		$teamArray = $team->toArray();
80
+		$this->assertNotEmpty($teamArray);
81
+
82
+		$newTeam = \App\Lib\DsManager\Models\Team::fromArray($teamArray);
83
+		$this->assertNotEmpty($newTeam->toArray());
84
+
85
+	}
86
+
87
+	/**
88
+	 * @group Teams
89
+	 */
90
+	public function testGetRandomTeams()
91
+	{
92
+		$rndF = new \App\Lib\DsManager\Helpers\RandomFiller("it_IT");
93
+
94
+		for ($i = 1; $i <= 20; $i++) {
95
+			$team = $rndF->getTeam();
96
+			$this->assertNotEmpty($team->name);
97
+			$this->assertNotEmpty($team->nationality);
98
+			$this->assertNotEmpty($team->getAvgSkill());
99
+			$this->assertNotEmpty($team->getAvgAge());
100
+		}
101
+	}
102
+
103
+	/**
104
+	 * @group Match
105
+	 */
106
+	public function testGetRandomMatch()
107
+	{
108
+		for ($i = 1; $i <= 30; $i++) {
109
+			$rndF = new \App\Lib\DsManager\Helpers\RandomFiller("it_IT");
110
+			$spanish = $rndF->getTeam();
111
+			$rndF = new \App\Lib\DsManager\Helpers\RandomFiller("it_IT");
112
+			$italian = $rndF->getTeam();
113
+			$this->assertNotEmpty($spanish);
114
+			$this->assertNotEmpty($italian);
115
+			$this->assertNotEmpty($italian->name);
116
+			$this->assertNotEmpty($spanish);
117
+			$this->assertNotEmpty($spanish->name);
118
+
119
+			$this->assertNotEmpty($italian->getAvgSkill());
120
+			$this->assertNotEmpty($spanish->getAvgSkill());
121
+			$result = (new \App\Lib\DsManager\Models\Match($italian, $spanish))->simulate()->toArray();
122
+			$this->assertNotEmpty($result);
123
+			$this->assertGreaterThanOrEqual(0, $result['goalHome']);
124
+			$this->assertGreaterThanOrEqual(0, $result['goalAway']);
125
+
126
+		}
127
+	}
128
+
129
+	/**
130
+	 * @group Match
131
+	 * @group MatchResult
132
+	 * @group matchresultoutput
133
+	 */
134
+	public function testMatchFromExistingTeams()
135
+	{
136
+		$teamHome = 1;
137
+		$teamAway = 2;
138
+		$homeOrm = \App\Lib\DsManager\Models\Orm\Team::with('roster', 'coach')->where(['id' => $teamHome])->first();
139
+		$awayOrm = \App\Lib\DsManager\Models\Orm\Team::with('roster', 'coach')->where(['id' => $teamAway])->first();
140
+		$home = \App\Lib\DsManager\Models\Team::fromArray($homeOrm->toArray());
141
+		$away = \App\Lib\DsManager\Models\Team::fromArray($awayOrm->toArray());
142
+
143
+		$match = new \App\Lib\DsManager\Models\Match($home, $away);
144
+		$result = $match->simulate()->toArray();
145
+		$this->assertNotEmpty($result);
146
+		$this->assertGreaterThanOrEqual(0, $result['goalAway']);
147
+		$this->assertGreaterThanOrEqual(0, $result['goalHome']);
148
+		if ($result['goalHome'] > 0) {
149
+			$this->assertNotEmpty($result['info']['scorers']['home']);
150
+			foreach ($result['info']['scorers']['home'] as $scorerHome) {
151
+				$this->assertEquals($scorerHome->team_id, $teamHome);
152
+			}
153
+		} else {
154
+			$this->assertEmpty($result['info']['scorers']['home']);
155
+		}
156
+		if ($result['goalAway'] > 0) {
157
+			$this->assertNotEmpty($result['info']['scorers']['away']);
158
+			foreach ($result['info']['scorers']['away'] as $scorerAway) {
159
+				$this->assertEquals($scorerAway->team_id, $teamAway);
160
+			}
161
+		} else {
162
+			$this->assertEmpty($result['info']['scorers']['away']);
163
+		}
164
+		if ($result['goalHome'] == $result['goalAway']) {
165
+			$this->assertTrue($result['info']['isDraw']);
166
+		} else {
167
+			$this->assertFalse($result['info']['isDraw']);
168
+		}
169
+	}
170
+
171
+	/**
172
+	 * @group Matches
173
+	 */
174
+	public function testGetRandomMatchesOneTeam()
175
+	{
176
+		$rndF = new \App\Lib\DsManager\Helpers\RandomFiller("it_IT");
177
+		$myTeam = $rndF->getTeam();
178
+		$win = 0;
179
+		$lost = 0;
180
+		$draw = 0;
181
+
182
+		for ($i = 1; $i <= 2; $i++) {
183
+
184
+			$randomLocale = \App\Lib\Helpers\Config::get('generic.localesSmall');
185
+			shuffle($randomLocale);
186
+			$randomLocale = $randomLocale[0];
187
+
188
+			$rndF = new \App\Lib\DsManager\Helpers\RandomFiller($randomLocale);
189
+			$opponent = $rndF->getTeam();
190
+			$result = (new \App\Lib\DsManager\Models\Match($opponent, $myTeam))->simulate()->toArray();
191
+			$this->assertNotEmpty($result);
192
+			$result = $result['info'];
193
+			if (!$result['isDraw']) {
194
+				if ($result['winner']['name'] == $myTeam->name) {
195
+					$win++;
196
+				} else {
197
+					$lost++;
198
+				}
199
+			} else {
200
+				$draw++;
201
+			}
202
+		}
203
+		$this->assertGreaterThanOrEqual(0, $win);
204
+		$this->assertGreaterThanOrEqual(0, $lost);
205
+		$this->assertGreaterThanOrEqual(0, $draw);
206
+	}
207
+
208
+	/**
209
+	 * @group Module
210
+	 */
211
+	public function testModule()
212
+	{
213
+		$rndF = new \App\Lib\DsManager\Helpers\RandomFiller("it_IT");
214
+		$team = $rndF->getTeam();
215
+
216
+		$modules = \App\Lib\Helpers\Config::get("modules.modules");
217
+		$modules = array_keys($modules);
218
+		foreach ($modules as $mod) {
219
+			$module = new \App\Lib\DsManager\Models\Module($mod);
220
+			$this->assertNotEmpty($module);
221
+			$this->assertNotNull($module->isDefensive());
222
+			$this->assertNotNull($module->isBalanced());
223
+			$this->assertNotNull($module->isOffensive());
224
+			$this->assertTrue(is_array($module->getRoleNeeded()));
225
+		}
226
+		$this->assertGreaterThan(0, $team->playersPerRoleArray());
227
+	}
228 228
 
229 229
 }
Please login to merge, or discard this patch.
api/database/seeds/BMatchesSeeder.php 1 patch
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -3,20 +3,20 @@
 block discarded – undo
3 3
 
4 4
 class BMatchesSeeder
5 5
 {
6
-    function run()
7
-    {
8
-        $teams = \App\Lib\DsManager\Models\Orm\Team::all()->toArray();
9
-        $halfTheTeams = count($teams) / 2;
10
-        $chunks = array_chunk($teams, $halfTheTeams);
11
-        $teamsSlice1 = $chunks[0];
12
-        $teamsSlice2 = $chunks[1];
13
-        for ($i = 0; $i < $halfTheTeams; $i++) {
14
-            \App\Lib\DsManager\Models\Orm\Match::create(
15
-                [
16
-                    'home_team_id' => $teamsSlice1[$i]['id'],
17
-                    'away_team_id' => $teamsSlice2[$i]['id']
18
-                ]
19
-            );
20
-        }
21
-    }
6
+	function run()
7
+	{
8
+		$teams = \App\Lib\DsManager\Models\Orm\Team::all()->toArray();
9
+		$halfTheTeams = count($teams) / 2;
10
+		$chunks = array_chunk($teams, $halfTheTeams);
11
+		$teamsSlice1 = $chunks[0];
12
+		$teamsSlice2 = $chunks[1];
13
+		for ($i = 0; $i < $halfTheTeams; $i++) {
14
+			\App\Lib\DsManager\Models\Orm\Match::create(
15
+				[
16
+					'home_team_id' => $teamsSlice1[$i]['id'],
17
+					'away_team_id' => $teamsSlice2[$i]['id']
18
+				]
19
+			);
20
+		}
21
+	}
22 22
 }
23 23
\ No newline at end of file
Please login to merge, or discard this patch.