【发布时间】:2015-12-09 21:18:17
【问题描述】:
我正在尝试在我的单元测试中运行 DatabaseMigrations,但我收到以下错误:
1) VisitStaffPagesTest::testLogBills
Error: Call to a member function call() on null
/Users/x/Documents/office/vendor/laravel/framework/src/Illuminate/Foundation/Testing/ApplicationTrait.php:312
/Users/x/Documents/office/vendor/laravel/framework/src/Illuminate/Foundation/Testing/DatabaseMigrations.php:12
来自 DatabaseMigrations:
public function runDatabaseMigrations()
{
$this->artisan('migrate'); // This is line 12
$this->beforeApplicationDestroyed(function () {
$this->artisan('migrate:rollback');
});
}
来自 ApplicationTrait:
public function artisan($command, $parameters = [])
{
return $this->code = $this->app['Illuminate\Contracts\Console\Kernel']->call($command, $parameters);
}
知道为什么我会收到此错误吗?
【问题讨论】:
-
显示你的
VisitStaffPagesTest类的代码 -
这里是:kopy.io/TZn9o
-
你在哪里定义了
createApplication方法? -
TestCase 中的内容:kopy.io/MfiqP
-
这里的新细节:这只发生在我的 Mac 上,而不是在我的实时服务器 (CentOS) 上。
标签: php laravel laravel-5 phpunit laravel-5.1