Last active
August 29, 2015 14:18
-
-
Save dancourse/7bc5d7aa230b5d01a727 to your computer and use it in GitHub Desktop.
Laracasts/TestDummy : setting up lots of similar factories pattern
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Grade | |
$grade_defaults = [ | |
'courseid' => 'factory:App\Models\Course', | |
'itemname' => $faker->sentence, | |
'itemtype' => $faker->word, | |
'score' => $faker->randomFloat(2, 0, 1), | |
'grademax' => 100 | |
]; | |
$factory('App\Models\Grade', | |
$grade_defaults | |
); | |
$factory('App\Models\Grade', 'grade_grademax_not_100', array_merge( | |
$grade_defaults, | |
[ | |
'grademax' => $faker->numberBetween(1,100) | |
]) | |
); | |
$factory('App\Models\Grade', 'grade_score_10', array_merge( | |
$grade_defaults, | |
[ | |
'score' => 10 | |
]) | |
); | |
$factory('App\Models\Grade', 'grade_score_90', array_merge( | |
$grade_defaults, | |
[ | |
'score' => 90 | |
]) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm aware this could be fe-ractored down, but I don't have the time. So please go wild!