|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
|
|
4
|
|
|
/** |
|
5
|
|
|
* Class OrmModelsTest |
|
6
|
|
|
*/ |
|
7
|
|
|
class OrmModelsTest extends \PHPUnit_Framework_TestCase |
|
|
|
|
|
|
8
|
|
|
{ |
|
9
|
|
|
|
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* @group OrmModels |
|
13
|
|
|
* @group PlayerOrm |
|
14
|
|
|
*/ |
|
15
|
|
View Code Duplication |
public function testPlayerOrmGetSet() |
|
|
|
|
|
|
16
|
|
|
{ |
|
17
|
|
|
$rndFiller = new \App\Lib\DsManager\Helpers\RandomFiller(); |
|
18
|
|
|
$playerM = $rndFiller->getPlayer(); |
|
19
|
|
|
$arrayPl = $playerM->toArray(); |
|
20
|
|
|
echo "\n"; |
|
21
|
|
|
print_r($arrayPl); |
|
22
|
|
|
echo "trying orm"; |
|
23
|
|
|
$playerO = \App\Lib\DsManager\Models\Orm\Player::create($arrayPl); |
|
24
|
|
|
print_r($playerO->toArray()); |
|
25
|
|
|
|
|
26
|
|
|
$newPlayer = \App\Lib\DsManager\Models\Player::fromArray($playerO->toArray()); |
|
27
|
|
|
print_r($newPlayer->toArray()); |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* @group OrmModels |
|
32
|
|
|
* @group CoachOrm |
|
33
|
|
|
*/ |
|
34
|
|
View Code Duplication |
public function testCoachOrmGetSet() |
|
|
|
|
|
|
35
|
|
|
{ |
|
36
|
|
|
$rndFiller = new \App\Lib\DsManager\Helpers\RandomFiller(); |
|
37
|
|
|
$coach = $rndFiller->getCoach(); |
|
38
|
|
|
$arrayPl = $coach->toArray(); |
|
39
|
|
|
echo "\n"; |
|
40
|
|
|
print_r($arrayPl); |
|
41
|
|
|
echo "trying orm"; |
|
42
|
|
|
$coachO = \App\Lib\DsManager\Models\Orm\Coach::create($arrayPl); |
|
43
|
|
|
print_r($coachO->toArray()); |
|
44
|
|
|
|
|
45
|
|
|
$newCoach = \App\Lib\DsManager\Models\Coach::fromArray($coachO->toArray()); |
|
46
|
|
|
print_r($newCoach->toArray()); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* @group OrmModels |
|
51
|
|
|
* @group TeamOrm |
|
52
|
|
|
*/ |
|
53
|
|
|
public function testTeamOrm() |
|
54
|
|
|
{ |
|
55
|
|
|
$rndFiller = new \App\Lib\DsManager\Helpers\RandomFiller(); |
|
56
|
|
|
$team = $rndFiller->getTeam($rndFiller->getLocale()); |
|
57
|
|
|
$teamArray = $team->toArray(); |
|
58
|
|
|
echo "\n"; |
|
59
|
|
|
print_r($teamArray); |
|
60
|
|
|
echo "orm\n"; |
|
61
|
|
|
$teamO = \App\Lib\DsManager\Models\Orm\Team::create($teamArray); |
|
62
|
|
|
foreach ($teamArray['roster'] as $player) { |
|
63
|
|
|
$player['team_id'] = $teamO->id; |
|
|
|
|
|
|
64
|
|
|
$playerO = \App\Lib\DsManager\Models\Orm\Player::create($player); |
|
|
|
|
|
|
65
|
|
|
} |
|
66
|
|
|
$teamArray['coach']['team_id'] = $teamO->id; |
|
|
|
|
|
|
67
|
|
|
\App\Lib\DsManager\Models\Orm\Coach::create($teamArray['coach']); |
|
68
|
|
|
|
|
69
|
|
|
print_r(\App\Lib\DsManager\Models\Orm\Team::with('roster')->with('coach')->where('id', '=', $teamO->id)->get()->toArray()); |
|
|
|
|
|
|
70
|
|
|
} |
|
71
|
|
|
} |
|
72
|
|
|
|
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.