I am wanting to write an end to end tests that at some stage through the process will search for a model with a certain id and will update some of the data against it. To avoid touching any real data when run on production environments I know we can use Laravel Faker to create fake instances of a model and then run opperations on it, i.e.
At the start of the test I could run:
$someModel = factory(SomeModel::class)->create();
Which from my understanding will create an instance in the database with its own unique id. Once I have finished with the test I have two questions about thaat instance in question...
- Does the entry still persist or is it auto deleted by design when using parent::teardown() or something of the like?
- If I have to manually delete it, will there be a skipped entry in the ids as say the instance I have created which was assigned id 20 no longer exists so anyone looking at the table weill see ids: ...18, 19, 21 ... and so on?
To me I am not quite sure if its ok to have dummy data being persisted in production databases or not, is this perfectly fine?