Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/Contracts/TransactionalNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
* Marker interface for notifications that must always be delivered,
* regardless of the user's email preferences or verification state.
*
* Account recovery, purchase receipts, and license/entitlement
* notifications fall into this category.
* Account recovery, purchase receipts, developer sale notifications,
* and license/entitlement notifications fall into this category.
*
* @see SuppressMailNotificationListener
*/
Expand Down
3 changes: 2 additions & 1 deletion app/Notifications/PluginSaleCompleted.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

namespace App\Notifications;

use App\Contracts\TransactionalNotification;
use App\Models\PluginPayout;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
use Illuminate\Support\Collection;

class PluginSaleCompleted extends Notification implements ShouldQueue
class PluginSaleCompleted extends Notification implements ShouldQueue, TransactionalNotification
{
use Queueable;

Expand Down
32 changes: 32 additions & 0 deletions tests/Feature/Notifications/PluginSaleCompletedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
namespace Tests\Feature\Notifications;

use App\Enums\PayoutStatus;
use App\Listeners\SuppressMailNotificationListener;
use App\Models\DeveloperAccount;
use App\Models\Plugin;
use App\Models\PluginLicense;
use App\Models\PluginPayout;
use App\Models\User;
use App\Notifications\PluginSaleCompleted;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Notifications\Events\NotificationSending;
use Tests\TestCase;

class PluginSaleCompletedTest extends TestCase
Expand Down Expand Up @@ -193,4 +195,34 @@ public function test_toarray_contains_payout_ids_and_total(): void
$this->assertEquals([$payout->id], $array['payout_ids']);
$this->assertEquals(2030, $array['total_developer_amount']);
}

public function test_email_is_sent_to_developers_who_opted_out_of_notification_emails(): void
{
$developer = User::factory()->create(['receives_notification_emails' => false]);

$event = new NotificationSending(
$developer,
new PluginSaleCompleted(collect()),
'mail',
);

$listener = new SuppressMailNotificationListener;

$this->assertTrue($listener->handle($event));
}

public function test_email_is_sent_to_developers_with_unverified_email_addresses(): void
{
$developer = User::factory()->unverified()->create();

$event = new NotificationSending(
$developer,
new PluginSaleCompleted(collect()),
'mail',
);

$listener = new SuppressMailNotificationListener;

$this->assertTrue($listener->handle($event));
}
}
Loading