Skip to content

chore(meta): use pest throws instead of internal phpunit methods #650

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 20, 2025
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion tests/Resources/Completions.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
'prompt' => 'hi',
'stream' => true,
]);
})->expectException(InvalidArgumentException::class);
})->throws(InvalidArgumentException::class);

test('create streamed', function () {
$response = new Response(
Expand Down
12 changes: 6 additions & 6 deletions tests/Testing/ClientFake.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
'model' => 'gpt-3.5-turbo-instruct',
'prompt' => 'PHP is ',
]);
})->expectExceptionMessage('The model `gpt-1` does not exist');
})->throws(\OpenAI\Exceptions\ErrorException::class, 'The model `gpt-1` does not exist');

it('throws an exception if there is no more fake response', function () {
$fake = new ClientFake([
Expand All @@ -77,7 +77,7 @@
'model' => 'gpt-3.5-turbo-instruct',
'prompt' => 'PHP is ',
]);
})->expectExceptionMessage('No fake responses left');
})->throws('No fake responses left');

it('allows to add more responses', function () {
$fake = new ClientFake([
Expand Down Expand Up @@ -136,7 +136,7 @@
$parameters['model'] === 'gpt-3.5-turbo-instruct' &&
$parameters['prompt'] === 'PHP is ';
});
})->expectException(ExpectationFailedException::class);
})->throws(ExpectationFailedException::class);

it('asserts a request was sent on the resource', function () {
$fake = new ClientFake([
Expand Down Expand Up @@ -186,7 +186,7 @@
]);

$fake->assertSent(Completions::class, 2);
})->expectException(ExpectationFailedException::class);
})->throws(ExpectationFailedException::class);

it('asserts a request was not sent', function () {
$fake = new ClientFake;
Expand All @@ -205,7 +205,7 @@
]);

$fake->assertNotSent(Completions::class);
})->expectException(ExpectationFailedException::class);
})->throws(ExpectationFailedException::class);

it('asserts a request was not sent on the resource', function () {
$fake = new ClientFake([
Expand All @@ -232,4 +232,4 @@
]);

$fake->assertNothingSent();
})->expectException(ExpectationFailedException::class);
})->throws(ExpectationFailedException::class);
4 changes: 2 additions & 2 deletions tests/Testing/ClientFakeResponses.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@
],
'input' => 'what was a positive news story from today?',
]);
})->expectExceptionMessage('No fake responses left');
})->throws('No fake responses left');

it('throws an exception if a request was not sent', function () {
$fake = new ClientFake([
Expand All @@ -155,4 +155,4 @@
$fake->assertSent(Responses::class, function ($method, $parameters) {
return $method === 'create';
});
})->expectException(ExpectationFailedException::class);
})->throws(ExpectationFailedException::class);