Level 13
I see nobody has replayed here but any updated on this??
I created a cron job to send notification emails. Cron job is working perfectly.
I need to test the cron job using the unit test. How can I write a unit test to check user data is existing or not?
I tried to implement a unit test for a cron job, but it is not working. I didn't try the unit test before. Any help would be appreciated.
I am using Laravel6.
Database Name = cronjob, Database username = homestead, Database password = secret
I created .env.testing file in root folder
##phpunit.xml
<server name="DB_CONNECTION" value="mysql"/>
<server name="DB_DATABASE" value=":memory:"/>
tests/Feature/EmailNotVerifiedCmdTest.php
public function testConsoleCommand()
{
// Here I want to check user details are available or not
// I don't want to check email sent or not.
$this->artisan('followUpNotification:EmailNotVerified');
$this->assertTrue(true);
}
app/Console/Commands/EmailNotVerifiedCommand.php
protected $signature = 'followUpNotification:EmailNotVerified';
public function handle()
{
$users = User::whereNull('email_verified_at')->get();
// Sending notification emails to users.
}
Please or to participate in this conversation.