Skip to content

Commit

Permalink
Merge pull request #74 from biig-io/fix/profiler-issues
Browse files Browse the repository at this point in the history
Fix #73
  • Loading branch information
Maxime Veber authored Mar 13, 2020
2 parents 2889a3a + 06470ac commit 9da4dd8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
11 changes: 11 additions & 0 deletions Tests/Debug/TraceableDomainEventDispatcherTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,17 @@ public function testItAddsPostPersistDomainRuleInterface()
$domainEventDispatcher->addPostPersistDomainRuleInterface($rule->reveal())->shouldBeCalled();
$tdispatcher->addPostPersistDomainRuleInterface($rule->reveal());
}

public function testTraceableNeverRegisterNullEvents()
{
$tdispatcher = new TraceableDomainEventDispatcher(new DomainEventDispatcher());
$tdispatcher->dispatch(new DomainEvent(), 'foo');
$tdispatcher->dispatch(new DomainEvent());

foreach ($tdispatcher->getEventsFired() as $firedEvents) {
$this->assertNotNull($firedEvents);
}
}
}

class FakeCalleable2 {
Expand Down
3 changes: 3 additions & 0 deletions src/Debug/TraceableDomainEventDispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ public function persistModel(ModelInterface $model)
*/
public function dispatch($event, string $eventName = null)
{
if ($eventName === null) {
$eventName = get_class($event);
}
$this->eventsFired[] = $eventName;

return parent::dispatch($event, $eventName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,12 @@
<table>
<thead>
<tr>
<th>Event</th>
<th>Priority</th>
<th>Listener</th>
</tr>
</thead>

{% set previous_event = (listeners|first).event %}
{% set previous_event = null %}
{% for listener in listeners %}
{% if loop.first or listener.event != previous_event %}
{% if not loop.first %}
Expand Down

0 comments on commit 9da4dd8

Please sign in to comment.