throws(InvalidSignatureException::class); test('unsigned closure with signer', function () { SerializableClosure::setSecretKey(null); $closure = function () { /*x*/ }; $value = serialize(new SerializableClosure($closure)); SerializableClosure::setSecretKey('secret'); unserialize($value); })->throws(InvalidSignatureException::class); test('signed closure without signer', function () { SerializableClosure::setSecretKey('secret'); $closure = function () { return true; }; $value = serialize(new SerializableClosure($closure)); SerializableClosure::setSecretKey(null); $closure = unserialize($value)->getClosure(); expect($closure())->toBeTrue(); });