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.8] Remove fire method #26392

Merged
merged 2 commits into from
Nov 5, 2018
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
13 changes: 0 additions & 13 deletions src/Illuminate/Events/Dispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,19 +169,6 @@ public function until($event, $payload = [])
return $this->dispatch($event, $payload, true);
}

/**
* Fire an event and call the listeners.
*
* @param string|object $event
* @param mixed $payload
* @param bool $halt
* @return array|null
*/
public function fire($event, $payload = [], $halt = false)
{
return $this->dispatch($event, $payload, $halt);
}

/**
* Fire an event and call the listeners.
*
Expand Down
13 changes: 0 additions & 13 deletions src/Illuminate/Support/Testing/Fakes/EventFake.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,19 +183,6 @@ public function flush($event)
//
}

/**
* Fire an event and call the listeners.
*
* @param string|object $event
* @param mixed $payload
* @param bool $halt
* @return array|null
*/
public function fire($event, $payload = [], $halt = false)
{
return $this->dispatch($event, $payload, $halt);
}

/**
* Fire an event and call the listeners.
*
Expand Down
28 changes: 14 additions & 14 deletions tests/Events/EventsDispatcherTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function testBasicEventExecution()
$d->listen('foo', function ($foo) {
$_SERVER['__event.test'] = $foo;
});
$d->fire('foo', ['bar']);
$d->dispatch('foo', ['bar']);
$this->assertEquals('bar', $_SERVER['__event.test']);
}

Expand All @@ -51,7 +51,7 @@ public function testContainerResolutionOfEventHandlers()
$container->shouldReceive('make')->once()->with('FooHandler')->andReturn($handler = m::mock(stdClass::class));
$handler->shouldReceive('onFooEvent')->once()->with('foo', 'bar');
$d->listen('foo', 'FooHandler@onFooEvent');
$d->fire('foo', ['foo', 'bar']);
$d->dispatch('foo', ['foo', 'bar']);
}

public function testContainerResolutionOfEventHandlersWithDefaultMethods()
Expand All @@ -60,7 +60,7 @@ public function testContainerResolutionOfEventHandlersWithDefaultMethods()
$container->shouldReceive('make')->once()->with('FooHandler')->andReturn($handler = m::mock(stdClass::class));
$handler->shouldReceive('handle')->once()->with('foo', 'bar');
$d->listen('foo', 'FooHandler');
$d->fire('foo', ['foo', 'bar']);
$d->dispatch('foo', ['foo', 'bar']);
}

public function testQueuedEventsAreFired()
Expand Down Expand Up @@ -104,7 +104,7 @@ public function testWildcardListeners()
$d->listen('bar.*', function () {
$_SERVER['__event.test'] = 'nope';
});
$d->fire('foo.bar');
$d->dispatch('foo.bar');

$this->assertEquals('wildcard', $_SERVER['__event.test']);
}
Expand All @@ -116,13 +116,13 @@ public function testWildcardListenersCacheFlushing()
$d->listen('foo.*', function () {
$_SERVER['__event.test'] = 'cached_wildcard';
});
$d->fire('foo.bar');
$d->dispatch('foo.bar');
$this->assertEquals('cached_wildcard', $_SERVER['__event.test']);

$d->listen('foo.*', function () {
$_SERVER['__event.test'] = 'new_wildcard';
});
$d->fire('foo.bar');
$d->dispatch('foo.bar');
$this->assertEquals('new_wildcard', $_SERVER['__event.test']);
}

Expand All @@ -134,7 +134,7 @@ public function testListenersCanBeRemoved()
$_SERVER['__event.test'] = 'foo';
});
$d->forget('foo');
$d->fire('foo');
$d->dispatch('foo');

$this->assertFalse(isset($_SERVER['__event.test']));
}
Expand All @@ -147,7 +147,7 @@ public function testWildcardListenersCanBeRemoved()
$_SERVER['__event.test'] = 'foo';
});
$d->forget('foo.*');
$d->fire('foo.bar');
$d->dispatch('foo.bar');

$this->assertFalse(isset($_SERVER['__event.test']));
}
Expand Down Expand Up @@ -181,14 +181,14 @@ public function testEventPassedFirstToWildcards()
$this->assertEquals('foo.bar', $event);
$this->assertEquals(['first', 'second'], $data);
});
$d->fire('foo.bar', ['first', 'second']);
$d->dispatch('foo.bar', ['first', 'second']);

$d = new Dispatcher;
$d->listen('foo.bar', function ($first, $second) {
$this->assertEquals('first', $first);
$this->assertEquals('second', $second);
});
$d->fire('foo.bar', ['first', 'second']);
$d->dispatch('foo.bar', ['first', 'second']);
}

public function testQueuedEventHandlersAreQueued()
Expand All @@ -205,7 +205,7 @@ public function testQueuedEventHandlersAreQueued()
});

$d->listen('some.event', TestDispatcherQueuedHandler::class.'@someMethod');
$d->fire('some.event', ['foo', 'bar']);
$d->dispatch('some.event', ['foo', 'bar']);
}

public function testClassesWork()
Expand All @@ -215,7 +215,7 @@ public function testClassesWork()
$d->listen(ExampleEvent::class, function () {
$_SERVER['__event.test'] = 'baz';
});
$d->fire(new ExampleEvent);
$d->dispatch(new ExampleEvent);

$this->assertSame('baz', $_SERVER['__event.test']);
}
Expand All @@ -227,7 +227,7 @@ public function testInterfacesWork()
$d->listen(SomeEventInterface::class, function () {
$_SERVER['__event.test'] = 'bar';
});
$d->fire(new AnotherEvent);
$d->dispatch(new AnotherEvent);

$this->assertSame('bar', $_SERVER['__event.test']);
}
Expand All @@ -242,7 +242,7 @@ public function testBothClassesAndInterfacesWork()
$d->listen(SomeEventInterface::class, function () {
$_SERVER['__event.test2'] = 'baar';
});
$d->fire(new AnotherEvent);
$d->dispatch(new AnotherEvent);

$this->assertSame('fooo', $_SERVER['__event.test1']);
$this->assertSame('baar', $_SERVER['__event.test2']);
Expand Down