'Laravel Illuminate Testing method for refreshing DB only at the start
I have a code that runs everyday and deletes some information from the database.
I am trying to test this code using artisan's test functionality and would like to be able to see the final result on phpmyadmin, however if I add Illuminate\Foundation\Testing\RefreshDatabase The DB seems to refresh at the start AND at the end.
Is there a way to refresh the database at the start only?
Here is a shortened sample of my code:
namespace Tests\Feature;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Server\Models\User;
use Server\Models\...; //call multiple models
use Tests\TestCase;
class CheckCountAttendanceTest extends TestCase
{
use RefreshDatabase;
public function testRemoveInactiveUsersFromTeams()
{
//create all necessary data using factory
factory(User::class)->create(); // etc...
//should run the code that deletes certain data
$this->artisan('count_attendance')->assertSuccessful();
}
}
So after I run php artisan test Tests\Feature\CheckCountAttendanceTest I would like to check if php artisan count_attendance worked the way I intended it to on the phpmyadmin panel.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
