Skip to content

Commit 98cae5c

Browse files
authored
[12.x] Fix event helper (#56773)
* Revert event helper return type * Add test * unnecessary comment
1 parent fbfeed8 commit 98cae5c

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/Illuminate/Foundation/helpers.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ function encrypt($value, $serialize = true): string
499499
* @param mixed $payload
500500
* @param bool $halt
501501
*/
502-
function event(...$args): ?array
502+
function event(...$args)
503503
{
504504
return app('events')->dispatch(...$args);
505505
}

tests/Foundation/FoundationHelpersTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Illuminate\Container\Container;
88
use Illuminate\Contracts\Cache\Repository as CacheRepository;
99
use Illuminate\Contracts\Config\Repository;
10+
use Illuminate\Contracts\Events\Dispatcher;
1011
use Illuminate\Contracts\Support\Responsable;
1112
use Illuminate\Foundation\Application;
1213
use Illuminate\Foundation\Mix;
@@ -49,6 +50,15 @@ public function testCache()
4950
$this->assertSame('default', cache('baz', 'default'));
5051
}
5152

53+
public function testEvents()
54+
{
55+
$app = new Application;
56+
$app['events'] = $dispatcher = m::mock(Dispatcher::class);
57+
58+
$dispatcher->shouldReceive('dispatch')->once()->with('a', 'b', 'c')->andReturn('foo');
59+
$this->assertSame('foo', event('a', 'b', 'c'));
60+
}
61+
5262
public function testMixDoesNotIncludeHost()
5363
{
5464
$app = new Application;

0 commit comments

Comments
 (0)