This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
info14884
Hello
I have a problem with PHPUnit testing with migrations. I want test my plugin and run follow test:
public function testCreateFirstCard()
{
$card = Card::create([
'name' => 'Test Card',
'code_number' => '123456789',
'card_color' => '#000000',
'code_type' => 'QR_CODE',
'lost_at' => Carbon::now()
]);
$this->assertEquals(1, $card->id);
}
Now I changed one field from is_lost
to lost_at
and now I get follow error:
Illuminate\Database\QueryException: SQLSTATE[HY000]: General error: 1 table nextlevels_driverscare_cards has no column named lost_at (SQL: insert into "nextlevels_driverscare_cards" ("name", "code_number", "card_color", "code_type", "lost_at", "updated_at", "created_at") values (Test Card, 123456789, #000000, QR_CODE, 2019-10-09 09:53:20, 2019-10-09 09:53:20, 2019-10-09 09:53:20))
I have no idea why PHPUnit not see my migrations. In the database table can I see this field. I hope anyone can help me.
Have a nice day.
Flynsarmy
Make sure your test class extends the PluginTestCase
class so it can include migrations and test with the database.
1-2 of 2