Skip to content

Commit f6ea6bc

Browse files
authored
chore(meta): use pest throws instead of internal phpunit methods (#650)
1 parent dd9efc2 commit f6ea6bc

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

tests/Resources/Completions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
'prompt' => 'hi',
5353
'stream' => true,
5454
]);
55-
})->expectException(InvalidArgumentException::class);
55+
})->throws(InvalidArgumentException::class);
5656

5757
test('create streamed', function () {
5858
$response = new Response(

tests/Testing/ClientFake.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
'model' => 'gpt-3.5-turbo-instruct',
6262
'prompt' => 'PHP is ',
6363
]);
64-
})->expectExceptionMessage('The model `gpt-1` does not exist');
64+
})->throws(\OpenAI\Exceptions\ErrorException::class, 'The model `gpt-1` does not exist');
6565

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

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

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

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

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

207207
$fake->assertNotSent(Completions::class);
208-
})->expectException(ExpectationFailedException::class);
208+
})->throws(ExpectationFailedException::class);
209209

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

234234
$fake->assertNothingSent();
235-
})->expectException(ExpectationFailedException::class);
235+
})->throws(ExpectationFailedException::class);

tests/Testing/ClientFakeResponses.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@
145145
],
146146
'input' => 'what was a positive news story from today?',
147147
]);
148-
})->expectExceptionMessage('No fake responses left');
148+
})->throws('No fake responses left');
149149

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

0 commit comments

Comments
 (0)