From the course: Building PHP Applications with Generative AI
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
Generating test data
From the course: Building PHP Applications with Generative AI
Generating test data
- [Instructor] Another common problem is creating test data for our programs. Let's see how AI can help us here. Let's test the person class by creating a set of objects designed to stretch the limits of the class. So the first thing I'll do is let Copilot know that we have a person class. "Here is a person class, "I'd like to create some test data for. "Please create 20 person objects "designed to test the class, each function, "and find issues with the code." Alright, so here's our person class, please create 20 person objects designed to test the class, each function, and find issues with the code. Alright, so this created a pretty comprehensive file. Actually, I'm going to just delete what I have here. And have this code take over this file, so if we run through this really quick, assuming person class is in Person.php, accurate. Creates a blank array, then a for each loop, to create a bunch of different pieces of data to generate different birthdays and names and roles. Then it…