Skip to content

Commit c8346ec

Browse files
committed
Use $this over self:: in tests
1 parent 1adcb16 commit c8346ec

File tree

12 files changed

+39
-39
lines changed

12 files changed

+39
-39
lines changed

tests/Bridge/OpenAi/DallE/Base64ImageTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ public function testItCreatesBase64Image()
3030

3131
public function testItThrowsExceptionWhenBase64ImageIsEmpty()
3232
{
33-
self::expectException(\InvalidArgumentException::class);
34-
self::expectExceptionMessage('The base64 encoded image generated must be given.');
33+
$this->expectException(\InvalidArgumentException::class);
34+
$this->expectExceptionMessage('The base64 encoded image generated must be given.');
3535

3636
new Base64Image('');
3737
}

tests/Bridge/OpenAi/DallE/UrlImageTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ public function testItCreatesUrlImage()
2929

3030
public function testItThrowsExceptionWhenUrlIsEmpty()
3131
{
32-
self::expectException(\InvalidArgumentException::class);
33-
self::expectExceptionMessage('The image url must be given.');
32+
$this->expectException(\InvalidArgumentException::class);
33+
$this->expectExceptionMessage('The image url must be given.');
3434

3535
new UrlImage('');
3636
}

tests/Bridge/OpenAi/Gpt/ResultConverterTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,8 @@ public function getResponse(): ResponseInterface
149149
];
150150
});
151151

152-
self::expectException(ContentFilterException::class);
153-
self::expectExceptionMessage('Content was filtered');
152+
$this->expectException(ContentFilterException::class);
153+
$this->expectExceptionMessage('Content was filtered');
154154

155155
$converter->convert(new RawHttpResult($httpResponse));
156156
}
@@ -161,8 +161,8 @@ public function testThrowsExceptionWhenNoChoices()
161161
$httpResponse = self::createMock(ResponseInterface::class);
162162
$httpResponse->method('toArray')->willReturn([]);
163163

164-
self::expectException(RuntimeException::class);
165-
self::expectExceptionMessage('Response does not contain choices');
164+
$this->expectException(RuntimeException::class);
165+
$this->expectExceptionMessage('Response does not contain choices');
166166

167167
$converter->convert(new RawHttpResult($httpResponse));
168168
}
@@ -183,8 +183,8 @@ public function testThrowsExceptionForUnsupportedFinishReason()
183183
],
184184
]);
185185

186-
self::expectException(RuntimeException::class);
187-
self::expectExceptionMessage('Unsupported finish reason "unsupported_reason"');
186+
$this->expectException(RuntimeException::class);
187+
$this->expectExceptionMessage('Unsupported finish reason "unsupported_reason"');
188188

189189
$converter->convert(new RawHttpResult($httpResponse));
190190
}

tests/Contract/JsonSchema/Attribute/ToolParameterTest.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function testValidEnum()
2828

2929
public function testInvalidEnumContainsNonString()
3030
{
31-
self::expectException(InvalidArgumentException::class);
31+
$this->expectException(InvalidArgumentException::class);
3232
$enum = ['value1', 2];
3333
new With(enum: $enum);
3434
}
@@ -42,7 +42,7 @@ public function testValidConstString()
4242

4343
public function testInvalidConstEmptyString()
4444
{
45-
self::expectException(InvalidArgumentException::class);
45+
$this->expectException(InvalidArgumentException::class);
4646
$const = ' ';
4747
new With(const: $const);
4848
}
@@ -56,7 +56,7 @@ public function testValidPattern()
5656

5757
public function testInvalidPatternEmptyString()
5858
{
59-
self::expectException(InvalidArgumentException::class);
59+
$this->expectException(InvalidArgumentException::class);
6060
$pattern = ' ';
6161
new With(pattern: $pattern);
6262
}
@@ -70,7 +70,7 @@ public function testValidMinLength()
7070

7171
public function testInvalidMinLengthNegative()
7272
{
73-
self::expectException(InvalidArgumentException::class);
73+
$this->expectException(InvalidArgumentException::class);
7474
new With(minLength: -1);
7575
}
7676

@@ -85,7 +85,7 @@ public function testValidMinLengthAndMaxLength()
8585

8686
public function testInvalidMaxLengthLessThanMinLength()
8787
{
88-
self::expectException(InvalidArgumentException::class);
88+
$this->expectException(InvalidArgumentException::class);
8989
new With(minLength: 10, maxLength: 5);
9090
}
9191

@@ -98,7 +98,7 @@ public function testValidMinimum()
9898

9999
public function testInvalidMinimumNegative()
100100
{
101-
self::expectException(InvalidArgumentException::class);
101+
$this->expectException(InvalidArgumentException::class);
102102
new With(minimum: -1);
103103
}
104104

@@ -111,7 +111,7 @@ public function testValidMultipleOf()
111111

112112
public function testInvalidMultipleOfNegative()
113113
{
114-
self::expectException(InvalidArgumentException::class);
114+
$this->expectException(InvalidArgumentException::class);
115115
new With(multipleOf: -5);
116116
}
117117

@@ -126,7 +126,7 @@ public function testValidExclusiveMinimumAndMaximum()
126126

127127
public function testInvalidExclusiveMaximumLessThanExclusiveMinimum()
128128
{
129-
self::expectException(InvalidArgumentException::class);
129+
$this->expectException(InvalidArgumentException::class);
130130
new With(exclusiveMinimum: 10, exclusiveMaximum: 5);
131131
}
132132

@@ -141,7 +141,7 @@ public function testValidMinItemsAndMaxItems()
141141

142142
public function testInvalidMaxItemsLessThanMinItems()
143143
{
144-
self::expectException(InvalidArgumentException::class);
144+
$this->expectException(InvalidArgumentException::class);
145145
new With(minItems: 5, maxItems: 1);
146146
}
147147

@@ -153,7 +153,7 @@ public function testValidUniqueItemsTrue()
153153

154154
public function testInvalidUniqueItemsFalse()
155155
{
156-
self::expectException(InvalidArgumentException::class);
156+
$this->expectException(InvalidArgumentException::class);
157157
new With(uniqueItems: false);
158158
}
159159

@@ -168,7 +168,7 @@ public function testValidMinContainsAndMaxContains()
168168

169169
public function testInvalidMaxContainsLessThanMinContains()
170170
{
171-
self::expectException(InvalidArgumentException::class);
171+
$this->expectException(InvalidArgumentException::class);
172172
new With(minContains: 3, maxContains: 1);
173173
}
174174

@@ -189,7 +189,7 @@ public function testValidMinPropertiesAndMaxProperties()
189189

190190
public function testInvalidMaxPropertiesLessThanMinProperties()
191191
{
192-
self::expectException(InvalidArgumentException::class);
192+
$this->expectException(InvalidArgumentException::class);
193193
new With(minProperties: 5, maxProperties: 1);
194194
}
195195

@@ -228,7 +228,7 @@ enum: ['value1', 'value2'],
228228

229229
public function testInvalidCombination()
230230
{
231-
self::expectException(InvalidArgumentException::class);
231+
$this->expectException(InvalidArgumentException::class);
232232
new With(minLength: -1, maxLength: -2);
233233
}
234234
}

tests/Message/Content/AudioTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ public function testFromDataUrlWithValidUrl()
3939

4040
public function testFromDataUrlWithInvalidUrl()
4141
{
42-
self::expectException(\InvalidArgumentException::class);
43-
self::expectExceptionMessage('Invalid audio data URL format.');
42+
$this->expectException(\InvalidArgumentException::class);
43+
$this->expectExceptionMessage('Invalid audio data URL format.');
4444

4545
Audio::fromDataUrl('invalid-url');
4646
}
@@ -55,8 +55,8 @@ public function testFromFileWithValidPath()
5555

5656
public function testFromFileWithInvalidPath()
5757
{
58-
self::expectException(\InvalidArgumentException::class);
59-
self::expectExceptionMessage('The file "foo.mp3" does not exist or is not readable.');
58+
$this->expectException(\InvalidArgumentException::class);
59+
$this->expectExceptionMessage('The file "foo.mp3" does not exist or is not readable.');
6060

6161
Audio::fromFile('foo.mp3');
6262
}

tests/Message/Content/BinaryTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ public function testCreateFromDataUrl()
3535

3636
public function testThrowsExceptionForInvalidDataUrl()
3737
{
38-
self::expectException(InvalidArgumentException::class);
39-
self::expectExceptionMessage('Invalid audio data URL format.');
38+
$this->expectException(InvalidArgumentException::class);
39+
$this->expectExceptionMessage('Invalid audio data URL format.');
4040

4141
File::fromDataUrl('invalid-data-url');
4242
}
@@ -77,7 +77,7 @@ public static function provideExistingFiles(): iterable
7777

7878
public function testThrowsExceptionForNonExistentFile()
7979
{
80-
self::expectException(\InvalidArgumentException::class);
80+
$this->expectException(\InvalidArgumentException::class);
8181

8282
File::fromFile('/non/existent/file.jpg');
8383
}

tests/Message/Content/ImageTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function testWithValidFile()
3434

3535
public function testFromBinaryWithInvalidFile()
3636
{
37-
self::expectExceptionMessage('The file "foo.jpg" does not exist or is not readable.');
37+
$this->expectExceptionMessage('The file "foo.jpg" does not exist or is not readable.');
3838

3939
Image::fromFile('foo.jpg');
4040
}

tests/Result/BaseResultTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function testItCanBeEnrichedWithARawResponse()
5555

5656
public function testItThrowsAnExceptionWhenSettingARawResponseTwice()
5757
{
58-
self::expectException(RawResultAlreadySetException::class);
58+
$this->expectException(RawResultAlreadySetException::class);
5959

6060
$result = $this->createResult();
6161
$rawResult = $this->createRawResult();

tests/Result/ChoiceResultTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ public function testChoiceResultCreation()
3535

3636
public function testChoiceResultWithNoChoices()
3737
{
38-
self::expectException(InvalidArgumentException::class);
39-
self::expectExceptionMessage('A choice result must contain at least two results.');
38+
$this->expectException(InvalidArgumentException::class);
39+
$this->expectExceptionMessage('A choice result must contain at least two results.');
4040

4141
new ChoiceResult();
4242
}

tests/Result/RawResultAwareTraitTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function testItCanBeEnrichedWithARawResponse()
3636

3737
public function testItThrowsAnExceptionWhenSettingARawResponseTwice()
3838
{
39-
self::expectException(RawResultAlreadySetException::class);
39+
$this->expectException(RawResultAlreadySetException::class);
4040

4141
$result = $this->createTestClass();
4242
$rawResponse = self::createMock(SymfonyHttpResponse::class);

0 commit comments

Comments
 (0)