diff --git a/src/Illuminate/Support/Facades/Bus.php b/src/Illuminate/Support/Facades/Bus.php index 9bbd4901ee94..611358afffca 100644 --- a/src/Illuminate/Support/Facades/Bus.php +++ b/src/Illuminate/Support/Facades/Bus.php @@ -20,11 +20,13 @@ class Bus extends Facade /** * Replace the bound instance with a fake. * - * @return void + * @return \Illuminate\Support\Testing\Fakes\BusFake */ public static function fake() { - static::swap(new BusFake); + static::swap($fake = new BusFake); + + return $fake; } /** diff --git a/src/Illuminate/Support/Facades/Event.php b/src/Illuminate/Support/Facades/Event.php index aefc49bb797b..73b65981cf3a 100755 --- a/src/Illuminate/Support/Facades/Event.php +++ b/src/Illuminate/Support/Facades/Event.php @@ -24,13 +24,15 @@ class Event extends Facade * Replace the bound instance with a fake. * * @param array|string $eventsToFake - * @return void + * @return \Illuminate\Support\Testing\Fakes\EventFake */ public static function fake($eventsToFake = []) { static::swap($fake = new EventFake(static::getFacadeRoot(), $eventsToFake)); Model::setEventDispatcher($fake); + + return $fake; } /** diff --git a/src/Illuminate/Support/Facades/Mail.php b/src/Illuminate/Support/Facades/Mail.php index bee470c7f8fb..00fc76f7304d 100755 --- a/src/Illuminate/Support/Facades/Mail.php +++ b/src/Illuminate/Support/Facades/Mail.php @@ -31,11 +31,13 @@ class Mail extends Facade /** * Replace the bound instance with a fake. * - * @return void + * @return \Illuminate\Support\Testing\Fakes\MailFake */ public static function fake() { - static::swap(new MailFake); + static::swap($fake = new MailFake); + + return $fake; } /** diff --git a/src/Illuminate/Support/Facades/Queue.php b/src/Illuminate/Support/Facades/Queue.php index 1f57ba0fec63..521d2eb21441 100755 --- a/src/Illuminate/Support/Facades/Queue.php +++ b/src/Illuminate/Support/Facades/Queue.php @@ -24,11 +24,13 @@ class Queue extends Facade /** * Replace the bound instance with a fake. * - * @return void + * @return \Illuminate\Support\Testing\Fakes\QueueFake */ public static function fake() { - static::swap(new QueueFake(static::getFacadeApplication())); + static::swap($fake = new QueueFake(static::getFacadeApplication())); + + return $fake; } /** diff --git a/src/Illuminate/Support/Facades/Storage.php b/src/Illuminate/Support/Facades/Storage.php index 5bcbfd654643..97426a1004bc 100644 --- a/src/Illuminate/Support/Facades/Storage.php +++ b/src/Illuminate/Support/Facades/Storage.php @@ -16,7 +16,7 @@ class Storage extends Facade * * @param string|null $disk * - * @return void + * @return \Illuminate\Filesystem\Filesystem */ public static function fake($disk = null) { @@ -26,22 +26,26 @@ public static function fake($disk = null) $root = storage_path('framework/testing/disks/'.$disk) ); - static::set($disk, self::createLocalDriver(['root' => $root])); + static::set($disk, $fake = self::createLocalDriver(['root' => $root])); + + return $fake; } /** * Replace the given disk with a persistent local testing disk. * * @param string|null $disk - * @return void + * @return \Illuminate\Filesystem\Filesystem */ public static function persistentFake($disk = null) { $disk = $disk ?: self::$app['config']->get('filesystems.default'); - static::set($disk, self::createLocalDriver([ + static::set($disk, $fake = self::createLocalDriver([ 'root' => storage_path('framework/testing/disks/'.$disk), ])); + + return $fake; } /**