Skip to content

Commit 77c978d

Browse files
authored
Merge pull request grokability#16416 from Godmartinz/expiring-asset-email-test
fix Expiring alert tests
2 parents f4f6dcb + 437b3cd commit 77c978d

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

app/Console/Commands/SendExpirationAlerts.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function __construct()
4242
public function handle()
4343
{
4444
$settings = Setting::getSettings();
45-
$threshold = $settings->alert_interval;
45+
$alert_interval = $settings->alert_interval;
4646

4747
if (($settings->alert_email != '') && ($settings->alerts_enabled == 1)) {
4848

@@ -51,18 +51,18 @@ public function handle()
5151
->map(fn($item) => trim($item)) // Trim each email
5252
->all();
5353
// Expiring Assets
54-
$assets = Asset::getExpiringWarrantee($threshold);
54+
$assets = Asset::getExpiringWarrantee($alert_interval);
5555

5656
if ($assets->count() > 0) {
57-
$this->info(trans_choice('mail.assets_warrantee_alert', $assets->count(), ['count' => $assets->count(), 'threshold' => $threshold]));
58-
Mail::to($recipients)->send(new ExpiringAssetsMail($assets, $threshold));
57+
$this->info(trans_choice('mail.assets_warrantee_alert', $assets->count(), ['count' => $assets->count(), 'threshold' => $alert_interval]));
58+
Mail::to($recipients)->send(new ExpiringAssetsMail($assets, $alert_interval));
5959
}
6060

6161
// Expiring licenses
62-
$licenses = License::getExpiringLicenses($threshold);
62+
$licenses = License::getExpiringLicenses($alert_interval);
6363
if ($licenses->count() > 0) {
64-
$this->info(trans_choice('mail.license_expiring_alert', $licenses->count(), ['count' => $licenses->count(), 'threshold' => $threshold]));
65-
Mail::to($recipients)->send(new ExpiringLicenseMail($licenses, $threshold));
64+
$this->info(trans_choice('mail.license_expiring_alert', $licenses->count(), ['count' => $licenses->count(), 'threshold' => $alert_interval]));
65+
Mail::to($recipients)->send(new ExpiringLicenseMail($licenses, $alert_interval));
6666
}
6767
} else {
6868
if ($settings->alert_email == '') {

app/Models/Asset.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -785,7 +785,7 @@ public static function getExpiringWarrantee($days = 30)
785785
->whereNotNull('warranty_months')
786786
->whereNotNull('purchase_date')
787787
->whereNull('deleted_at')
788-
->whereRaw('DATE_ADD(`purchase_date`,INTERVAL `warranty_months` MONTH) <= DATE(NOW() + INTERVAL '
788+
->whereRaw('DATE_ADD(`purchase_date`, INTERVAL `warranty_months` MONTH) <= DATE_ADD(NOW(), INTERVAL '
789789
. $days
790790
. ' DAY) AND DATE_ADD(`purchase_date`, INTERVAL `warranty_months` MONTH) > NOW()')
791791
->orderByRaw('DATE_ADD(`purchase_date`,INTERVAL `warranty_months` MONTH)')

tests/Feature/Notifications/Email/ExpiringAlertsNotificationTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function testExpiringAssetsEmailNotification()
3131
'archived' => 0,
3232
'deleted_at' => null,
3333
]);
34-
34+
3535
$expiredAsset = Asset::factory()->create([
3636
'purchase_date' => now()->subDays(370)->format('Y-m-d'),
3737
'warranty_months' => 12,

0 commit comments

Comments
 (0)