diff --git a/app/Console/Commands/SendAcceptanceReminder.php b/app/Console/Commands/SendAcceptanceReminder.php index f4ab2c5b68..89a5b6167a 100644 --- a/app/Console/Commands/SendAcceptanceReminder.php +++ b/app/Console/Commands/SendAcceptanceReminder.php @@ -64,6 +64,7 @@ class SendAcceptanceReminder extends Command ->groupBy(function($item) { return $item['acceptance']->assignedTo ? $item['acceptance']->assignedTo->id : ''; }); + $no_email_list= []; foreach($unacceptedAssetGroups as $unacceptedAssetGroup) { // The [0] is weird, but it allows for the item_count to work and grabs the appropriate info for each user. @@ -72,7 +73,10 @@ class SendAcceptanceReminder extends Command $locale = $acceptance->assignedTo?->locale; $email = $acceptance->assignedTo?->email; if(!$email){ - $this->info($acceptance->assignedTo?->present()->fullName().' has no email address.'); + $no_email_list[] = [ + 'id' => $acceptance->assignedTo->id, + 'name' => $acceptance->assignedTo->present()->fullName(), + ]; } $item_count = $unacceptedAssetGroup->count(); @@ -86,6 +90,14 @@ class SendAcceptanceReminder extends Command } $this->info($count.' users notified.'); + $headers = ['ID', 'Name']; + $rows = []; + + foreach ($no_email_list as $user) { + $rows[] = [$user['id'], $user['name']]; + } + $this->info("The following users do not have an email address:"); + $this->table($headers, $rows); return 0; } diff --git a/tests/Feature/Console/SendAcceptanceReminderTest.php b/tests/Feature/Console/SendAcceptanceReminderTest.php index 9743a9db49..ee28e09355 100644 --- a/tests/Feature/Console/SendAcceptanceReminderTest.php +++ b/tests/Feature/Console/SendAcceptanceReminderTest.php @@ -43,9 +43,13 @@ class SendAcceptanceReminderTest extends TestCase CheckoutAcceptance::factory()->pending()->create([ 'assigned_to_id' => $userA->id, ]); - + $headers = ['ID', 'Name']; + $rows = [ + [$userA->id, $userA->present()->fullName()], + ]; $this->artisan('snipeit:acceptance-reminder') - ->expectsOutput($userA->present()->fullName().' has no email address.') + ->expectsOutput("The following users do not have an email address:") + ->expectsTable($headers, $rows) ->assertExitCode(0); Mail::assertNotSent(UnacceptedAssetReminderMail::class);