diff --git a/tests/Resources/Completions.php b/tests/Resources/Completions.php index ecf7adb7..21b53aef 100644 --- a/tests/Resources/Completions.php +++ b/tests/Resources/Completions.php @@ -52,7 +52,7 @@ 'prompt' => 'hi', 'stream' => true, ]); -})->expectException(InvalidArgumentException::class); +})->throws(InvalidArgumentException::class); test('create streamed', function () { $response = new Response( diff --git a/tests/Testing/ClientFake.php b/tests/Testing/ClientFake.php index 6f09fb1f..064c9d27 100644 --- a/tests/Testing/ClientFake.php +++ b/tests/Testing/ClientFake.php @@ -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([ @@ -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([ @@ -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([ @@ -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; @@ -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([ @@ -232,4 +232,4 @@ ]); $fake->assertNothingSent(); -})->expectException(ExpectationFailedException::class); +})->throws(ExpectationFailedException::class); diff --git a/tests/Testing/ClientFakeResponses.php b/tests/Testing/ClientFakeResponses.php index 8db5636f..10e57a5d 100644 --- a/tests/Testing/ClientFakeResponses.php +++ b/tests/Testing/ClientFakeResponses.php @@ -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([ @@ -155,4 +155,4 @@ $fake->assertSent(Responses::class, function ($method, $parameters) { return $method === 'create'; }); -})->expectException(ExpectationFailedException::class); +})->throws(ExpectationFailedException::class);