0
我有一個很奇怪的問題。我試圖用phpunit在我的api中測試以下函數。Laravel DatabaseTransactions
use DatabaseTransactions;
public $url = 'test.dev';
/** @test */
function show_school_stagiair_authorized()
{
factory(Company::class,1)
->create(['CompanyId' => 1]);
factory(School::class,1)
->create(['SchoolId' => 1, 'CompanyId' => 1]);
factory(Mentor::class,1)
->create(['MentorId' => 1, 'SchoolId' => 1, 'CompanyId' => 1]);
factory(Department::class,1)
->create(['DepartmentId' => 1,'CompanyId' => 1]);
factory(Intern::class,1)
->create(['InternId' => 1, 'MentorId' => 1]);
factory(Employee::class,1)
->create(['EmployeeId' => 1, 'RoleId' => 1, 'DepartmentId' => 1, 'InternId' => 1, ]);
$client = new Client();
$res = $client->request('POST', $this->url.'/api/v1/school/1',[
'form_params' => [
'currentUserId' => 1
]
]);
$this->assertEquals(200, $res->getStatusCode());
}
這將返回狀態碼500.但是,當我刪除use DatabaseTransaction
它的工作!?在我的config/database.php
中,我已將默認設置設置爲測試連接'default' => env('DB_CONNECTION', 'mysql_testing'),
有人可以告訴我我做錯了什麼。
use DatabaseTransactions;
有: