Skip to content

Commit

Permalink
Return the fake object when Notification::fake()
Browse files Browse the repository at this point in the history
  • Loading branch information
mathieutu committed Dec 12, 2017
1 parent 9926672 commit 7934447
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/Illuminate/Support/Facades/Notification.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ class Notification extends Facade
/**
* Replace the bound instance with a fake.
*
* @return void
* @return \Illuminate\Support\Testing\Fakes\NotificationFake
*/
public static function fake()
{
static::swap(new NotificationFake);
static::swap($fake = new NotificationFake);

return $fake;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Orchestra\Testbench\TestCase;
use Illuminate\Notifications\Notification;
use Illuminate\Notifications\AnonymousNotifiable;
use Illuminate\Support\Testing\Fakes\NotificationFake;
use Illuminate\Support\Facades\Notification as NotificationFacade;

/**
Expand Down Expand Up @@ -37,7 +38,9 @@ public function test_mail_is_sent()

public function test_faking()
{
NotificationFacade::fake();
$fake = NotificationFacade::fake();

$this->assertInstanceOf(NotificationFake::class, $fake);

$notifiable = (new AnonymousNotifiable())
->route('testchannel', 'enzo')
Expand Down

0 comments on commit 7934447

Please sign in to comment.