拉雷维尔在美国做了很多准备工作
setUp()
中的方法
TestCase
setUpBeforeClass()
方法,这就是为什么工厂还没有加载的原因。
拉威尔家
班
setup
方法(
see class
/**
* Setup the test environment.
*
* @return void
*/
protected function setUp()
{
if (! $this->app) {
$this->refreshApplication();
}
$this->setUpTraits();
foreach ($this->afterApplicationCreatedCallbacks as $callback) {
call_user_func($callback);
}
Facade::clearResolvedInstances();
Model::setEventDispatcher($this->app['events']);
$this->setUpHasRun = true;
}
更改代码以使用
setUp
取而代之的是:
protected static function setUp() : void
{
parent::setUp();
factory( Location::class )->make( ["id" => self::FAKEID] )->save();
}