shouldReceive('getRecipients') ->with('parent') ->andReturn([ ['id' => 10, 'email' => 'parent1@example.com', 'phone' => '5551112222'], ['id' => 11, 'email' => 'parent2@example.com', 'phone' => null], ]); $dispatcher = Mockery::mock(NotificationDispatchService::class); $dispatcher->shouldReceive('sendEmail')->once(); $dispatcher->shouldReceive('sendSms')->once(); $service = new NotificationSendService($recipients, $dispatcher); $result = $service->send([ 'title' => 'Announcement', 'message' => 'Hello parents', 'target_group' => 'parent', 'channels' => ['in_app', 'email', 'sms'], ], 99); $this->assertTrue($result['ok']); $this->assertSame(2, $result['recipient_count']); $this->assertDatabaseHas('notifications', [ 'title' => 'Announcement', 'target_group' => 'parent', ]); $this->assertSame(1, Notification::query()->count()); $this->assertSame(2, UserNotification::query()->count()); } }