You are doing a get request to a method named store()?
Jan 14, 2023
9
Level 4
Pest and Exceptions
Here's an oddity.
I have a test that's about as simple as they get ...
it('throws an exception if a tenant cannot be found by hashed id', function () {
get('/verify/xxxx/xxxx');
})->throws(TenancyException::class);
The controller method it's tesing goes like this ...
public function store(string $hashedId, string $token): void
{
$tenant = Tenant::findHash($hashedId);
throw_unless($tenant, TenancyException::class, 'Token with hashed id not found');
$tenantToken = $tenant->token(TokenType::ACTIVATION);
throw_unless($tenantToken->token == $token, TenancyException::class, 'Token is invalid');
$tenant->status = TenantStatus::LIVE;
$tenant->save();
}
I'm getting the rather odd result of the test ...
Failed asserting that exception of type "App\Exceptions\TenancyException" is thrown.
The following exception occurred during the last request:
App\Exceptions\TenancyException: Token with hashed id not found in
Is anybody able to shed some light on why this test is failing? It doesn't make any sense to me!
Level 4
Please or to participate in this conversation.