Last active
February 21, 2018 03:35
-
-
Save thmsbkkr/d1e85bf07810fd8b29d4f2a45f58c0d9 to your computer and use it in GitHub Desktop.
A helper trait for working with factories in tests
This file contains hidden or 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
<?php | |
namespace Tests; | |
trait FactoryHelpers | |
{ | |
public function create($class, $attributes = [], $times = null) | |
{ | |
return factory($class, $times)->create($attributes); | |
} | |
public function make($class, $attributes = [], $times = null) | |
{ | |
return factory($class, $times)->make($attributes); | |
} | |
public function createState($class, $state, $attributes = [], $times = null) | |
{ | |
return factory($class, $times)->states($state)->create($attributes); | |
} | |
public function makeState($class, $state, $attributes = [], $times = null) | |
{ | |
return factory($class, $times)->states($state)->make($attributes); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment