From d4e50dd02841fc96bbb27e86e3cf34787222b3a6 Mon Sep 17 00:00:00 2001 From: Michael Babker Date: Sun, 2 Aug 2020 22:19:11 -0500 Subject: [PATCH] Replace use of deprecated TestCase::at() method (ref sebastianbergmann/phpunit#4297) --- tests/BreadcrumbsGeneratorTest.php | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/tests/BreadcrumbsGeneratorTest.php b/tests/BreadcrumbsGeneratorTest.php index 3836ca8..7cbfe62 100644 --- a/tests/BreadcrumbsGeneratorTest.php +++ b/tests/BreadcrumbsGeneratorTest.php @@ -8,7 +8,7 @@ use BabDev\Breadcrumbs\Events\BeforeBreadcrumbGenerated; use BabDev\Breadcrumbs\Exceptions\InvalidBreadcrumbException; use Illuminate\Contracts\Events\Dispatcher; -use PHPUnit\Framework\TestCase; +use Orchestra\Testbench\TestCase; class BreadcrumbsGeneratorTest extends TestCase { @@ -36,21 +36,16 @@ public function testGeneratesABreadcrumb(): void public function testGeneratesABreadcrumbWithBeforeAndAfterEvents(): void { - $dispatcher = $this->createMock(Dispatcher::class); - - $dispatcher->expects($this->at(0)) - ->method('dispatch') - ->with($this->isInstanceOf(BeforeBreadcrumbGenerated::class)) - ->willReturnCallback(static function (BeforeBreadcrumbGenerated $event): void { - $event->breadcrumbs->push('Home', '/'); - }); - - $dispatcher->expects($this->at(1)) - ->method('dispatch') - ->with($this->isInstanceOf(AfterBreadcrumbGenerated::class)) - ->willReturnCallback(static function (AfterBreadcrumbGenerated $event): void { - $event->breadcrumbs->push('Page 2', '/page-2'); - }); + /** @var Dispatcher $dispatcher */ + $dispatcher = $this->app->make('events'); + + $dispatcher->listen(BeforeBreadcrumbGenerated::class, static function (BeforeBreadcrumbGenerated $event): void { + $event->breadcrumbs->push('Home', '/'); + }); + + $dispatcher->listen(AfterBreadcrumbGenerated::class, static function (AfterBreadcrumbGenerated $event): void { + $event->breadcrumbs->push('Page 2', '/page-2'); + }); $callbacks = [ 'blog' => static function (BreadcrumbsGeneratorContract $trail): void {