Skip to content
Closed
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
11 changes: 9 additions & 2 deletions src/EntityContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,21 @@ public function delay(Closure $self, DateTimeInterface $until = new DateTimeImmu
throw new Exception('Cannot delay a function with parameters');
}

// create the spy proxy
// create the spy proxy and capture the invoked operation
$spy = $this->spyProxy->define($interfaces[0]);
$operationName = null;
$arguments = null;
$class = new $spy($operationName, $arguments);
$self->bindTo($class);
$self = $self->bindTo($class, $class);

try {
$self();
} catch (Throwable) {
// the spy always throws when an operation is invoked
}

if ($operationName === null || $arguments === null) {
throw new Exception('Did not call an operation');
}

$this->delayUntil($operationName, $arguments, $until);
Expand Down
Loading