Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.5] Fix NotificationFake interfaces and return fake object. #22396

Merged
merged 2 commits into from
Dec 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
3 changes: 2 additions & 1 deletion src/Illuminate/Support/Testing/Fakes/NotificationFake.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
use Illuminate\Support\Collection;
use PHPUnit\Framework\Assert as PHPUnit;
use Illuminate\Contracts\Notifications\Factory as NotificationFactory;
use Illuminate\Contracts\Notifications\Dispatcher as NotificationDispatcher;

class NotificationFake implements NotificationFactory
class NotificationFake implements NotificationFactory, NotificationDispatcher
{
/**
* All of the notifications that have been sent.
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