lionweb
1 month ago
163
1
Testing

Commands testing

Posted 1 month ago by lionweb

Hello,

I want to test database changes performed by scheduled command, but after I creaded testing data and call command which should remove row, I still see that row in DB, despite the fact that command outside testing environment works.

So my question is, what is wrong with this code:

factory(Course::class)->create();
$this->assertDatabaseHas('courses', ["id" => 1]);  //true
$this->artisan('reset:course')->expectsOutput('Course removed');  //true
$this->assertDatabaseMissing('courses', ["id" => 1]); //false

Please sign in or create an account to participate in this conversation.