Engineering note · Laravel

Use Artisan Commands for Testing

By Published Updated

Laravel

Integrate Artisan commands into your testing workflow to automate testing tasks and streamline the testing process. Run commands to seed databases, clear caches, or perform other setup and cleanup tasks for testing purposes.

CODE SAMPLE Code snippet
// Run Artisan commands in your PHPUnit test cases
public function testDatabaseIsSeeded()
{
    $this->artisan('db:seed')->assertExitCode(0);
}

More engineering notes

Optimize Queries with Eager Loading

Reduce the number of database queries by using Eager Loading. Eager Loading helps you load related m...

Schedule Tasks with Artisan Scheduler

Automate recurring tasks such as sending emails, generating reports, or cleaning up the database usi...