Need Support for Process Isolation
SanderCokart opened this issue · 1 comments
SanderCokart commented
Problem
So the situation I have is that I have a model called Roles, this gets seeded in the BeforeEach. Problem is that RefreshDatabase does not truncate the ID's, I have for example added constants on the Roles model like this:
class Role extends Model
{
use HasFactory;
const USER = 1;
const ADMIN = 2;
public $timestamps = false;
protected $guarded = [];
public function users(): BelongsToMany
{
return $this->belongsToMany(User::class);
}
What happens is that by test 25 the Role id is at 51 instead of 1 and 2.
So that I can use Role::USER
or Role::ADMIN
where applicable instead of having to use Role::where(name, 'USER');
Which is the only way to fix the testing suite right now.
Alternatives
Any alternative suggestions are welcome to be posted here.
How do you deal with this situation?
Workaround
use Role::where(name, 'USER');
in tests.
nunomaduro commented
Feel free to try to add support for process isolation. At this time, Pest does not support that feature.