diff --git a/src/Illuminate/Support/Facades/Bus.php b/src/Illuminate/Support/Facades/Bus.php index 09fd4491004f..ab410edc95d2 100644 --- a/src/Illuminate/Support/Facades/Bus.php +++ b/src/Illuminate/Support/Facades/Bus.php @@ -60,10 +60,12 @@ class Bus extends Facade */ public static function fake($jobsToFake = [], BatchRepository $batchRepository = null) { - return tap(new BusFake(static::getFacadeRoot(), $jobsToFake, $batchRepository), function ($fake) { - if (! static::isFake()) { - static::swap($fake); - } + $actualDispatcher = static::isFake() + ? static::getFacadeRoot()->dispatcher + : static::getFacadeRoot(); + + return tap(new BusFake($actualDispatcher, $jobsToFake, $batchRepository), function ($fake) { + static::swap($fake); }); } diff --git a/src/Illuminate/Support/Facades/Event.php b/src/Illuminate/Support/Facades/Event.php index 879792915bbc..b5d14f8fb9e4 100755 --- a/src/Illuminate/Support/Facades/Event.php +++ b/src/Illuminate/Support/Facades/Event.php @@ -47,13 +47,15 @@ class Event extends Facade */ public static function fake($eventsToFake = []) { - return tap(new EventFake(static::getFacadeRoot(), $eventsToFake), function ($fake) { - if (! static::isFake()) { - static::swap($fake); + $actualDispatcher = static::isFake() + ? static::getFacadeRoot()->dispatcher + : static::getFacadeRoot(); - Model::setEventDispatcher($fake); - Cache::refreshEventDispatcher(); - } + return tap(new EventFake($actualDispatcher, $eventsToFake), function ($fake) { + static::swap($fake); + + Model::setEventDispatcher($fake); + Cache::refreshEventDispatcher(); }); } diff --git a/src/Illuminate/Support/Facades/Mail.php b/src/Illuminate/Support/Facades/Mail.php index 9b17d364781a..014a3611e2ff 100755 --- a/src/Illuminate/Support/Facades/Mail.php +++ b/src/Illuminate/Support/Facades/Mail.php @@ -65,10 +65,12 @@ class Mail extends Facade */ public static function fake() { - return tap(new MailFake(static::getFacadeRoot()), function ($fake) { - if (! static::isFake()) { - static::swap($fake); - } + $actualMailManager = static::isFake() + ? static::getFacadeRoot()->manager + : static::getFacadeRoot(); + + return tap(new MailFake($actualMailManager), function ($fake) { + static::swap($fake); }); } diff --git a/src/Illuminate/Support/Facades/Notification.php b/src/Illuminate/Support/Facades/Notification.php index bc5154f245af..e82aa0529d65 100644 --- a/src/Illuminate/Support/Facades/Notification.php +++ b/src/Illuminate/Support/Facades/Notification.php @@ -49,10 +49,8 @@ class Notification extends Facade */ public static function fake() { - return tap(new NotificationFake(), function ($fake) { - if (! static::isFake()) { - static::swap($fake); - } + return tap(new NotificationFake, function ($fake) { + static::swap($fake); }); } diff --git a/src/Illuminate/Support/Facades/Queue.php b/src/Illuminate/Support/Facades/Queue.php index 657b5f7c1b19..45b97e7a18bc 100755 --- a/src/Illuminate/Support/Facades/Queue.php +++ b/src/Illuminate/Support/Facades/Queue.php @@ -76,10 +76,12 @@ public static function popUsing($workerName, $callback) */ public static function fake($jobsToFake = []) { - return tap(new QueueFake(static::getFacadeApplication(), $jobsToFake, static::getFacadeRoot()), function ($fake) { - if (! static::isFake()) { - static::swap($fake); - } + $actualQueueManager = static::isFake() + ? static::getFacadeRoot()->queue + : static::getFacadeRoot(); + + return tap(new QueueFake(static::getFacadeApplication(), $jobsToFake, $actualQueueManager), function ($fake) { + static::swap($fake); }); } diff --git a/src/Illuminate/Support/Testing/Fakes/BusFake.php b/src/Illuminate/Support/Testing/Fakes/BusFake.php index d920459ee4b8..55b143df8255 100644 --- a/src/Illuminate/Support/Testing/Fakes/BusFake.php +++ b/src/Illuminate/Support/Testing/Fakes/BusFake.php @@ -20,7 +20,7 @@ class BusFake implements Fake, QueueingDispatcher * * @var \Illuminate\Contracts\Bus\QueueingDispatcher */ - protected $dispatcher; + public $dispatcher; /** * The job types that should be intercepted instead of dispatched. diff --git a/src/Illuminate/Support/Testing/Fakes/EventFake.php b/src/Illuminate/Support/Testing/Fakes/EventFake.php index 26a40b907d79..385a5348f9c2 100644 --- a/src/Illuminate/Support/Testing/Fakes/EventFake.php +++ b/src/Illuminate/Support/Testing/Fakes/EventFake.php @@ -20,7 +20,7 @@ class EventFake implements Dispatcher, Fake * * @var \Illuminate\Contracts\Events\Dispatcher */ - protected $dispatcher; + public $dispatcher; /** * The event types that should be intercepted instead of dispatched. diff --git a/src/Illuminate/Support/Testing/Fakes/MailFake.php b/src/Illuminate/Support/Testing/Fakes/MailFake.php index b982d2229e9e..d47373ffae12 100644 --- a/src/Illuminate/Support/Testing/Fakes/MailFake.php +++ b/src/Illuminate/Support/Testing/Fakes/MailFake.php @@ -22,7 +22,7 @@ class MailFake implements Factory, Fake, Mailer, MailQueue * * @var MailManager */ - protected $manager; + public $manager; /** * The mailer currently being used to send a message. diff --git a/src/Illuminate/Support/Testing/Fakes/QueueFake.php b/src/Illuminate/Support/Testing/Fakes/QueueFake.php index fef069713408..7218644ba860 100644 --- a/src/Illuminate/Support/Testing/Fakes/QueueFake.php +++ b/src/Illuminate/Support/Testing/Fakes/QueueFake.php @@ -20,7 +20,7 @@ class QueueFake extends QueueManager implements Fake, Queue * * @var \Illuminate\Contracts\Queue\Queue */ - protected $queue; + public $queue; /** * The job types that should be intercepted instead of pushed to the queue.