diff --git a/lib/Models/Subscriber.php b/lib/Models/Subscriber.php index a872d90ec3..59f7863a49 100644 --- a/lib/Models/Subscriber.php +++ b/lib/Models/Subscriber.php @@ -648,7 +648,9 @@ class Subscriber extends Model { return self::whereIn('status', array( self::STATUS_SUBSCRIBED, self::STATUS_UNCONFIRMED - ))->count(); + )) + ->whereNull('deleted_at') + ->count(); } static function bulkTrash($orm) { diff --git a/tests/unit/Models/SubscriberTest.php b/tests/unit/Models/SubscriberTest.php index 011bd96a7a..80ab2db7a8 100644 --- a/tests/unit/Models/SubscriberTest.php +++ b/tests/unit/Models/SubscriberTest.php @@ -465,6 +465,12 @@ class SubscriberTest extends MailPoetTest { 'status' => Subscriber::STATUS_UNSUBSCRIBED )); + $subscriber_4 = Subscriber::createOrUpdate(array( + 'email' => 'subscriber_4@mailpoet.com', + 'status' => Subscriber::STATUS_SUBSCRIBED, + 'deleted_at' => Carbon::now()->toDateTimeString() + )); + // counts only subscribed & unconfirmed users $total = Subscriber::getTotalSubscribers(); expect($total)->equals(2);