You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Error : Call to a member function getMessage() on null
This doesn't work because whatever the Closure is bound to at test setup time (when provideClosure() is invoked) is not the same object as when test() is invoked. The only way around this is to rebind the closure when it is invoked, i.e. do the following:
/** * @dataProvider provideClosure */publicfunctiontest(\Closure$closure): void
{
// Workaround: rebind closure to this test instance.
\Closure::bind($closure, $this)();
}
If possible, closures created by data providers should be bound to the same test instance as the test class they were created by, to avoid betraying user's expectations and having to employ this ugly workaround.
The text was updated successfully, but these errors were encountered:
This doesn't work because whatever the
Closure
is bound to at test setup time (whenprovideClosure()
is invoked) is not the same object as whentest()
is invoked. The only way around this is to rebind the closure when it is invoked, i.e. do the following:If possible, closures created by data providers should be bound to the same test instance as the test class they were created by, to avoid betraying user's expectations and having to employ this ugly workaround.
The text was updated successfully, but these errors were encountered: