Skip to content

Commit

Permalink
tests: Enable ``PHPUnitSetList::PHPUNIT_CODE_QUALITY (#88)
Browse files Browse the repository at this point in the history
  • Loading branch information
OskarStark authored Oct 1, 2024
1 parent 71a1184 commit c06f8fb
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 43 deletions.
7 changes: 7 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

use Rector\Config\RectorConfig;
use Rector\Php74\Rector\Closure\ClosureToArrowFunctionRector;
use Rector\PHPUnit\CodeQuality\Rector\Class_\PreferPHPUnitThisCallRector;
use Rector\PHPUnit\Rector\Class_\PreferPHPUnitSelfCallRector;
use Rector\PHPUnit\Set\PHPUnitSetList;

return RectorConfig::configure()
Expand All @@ -16,9 +18,14 @@
->withSets([
PHPUnitSetList::PHPUNIT_110,
PHPUnitSetList::ANNOTATIONS_TO_ATTRIBUTES,
PHPUnitSetList::PHPUNIT_CODE_QUALITY,
])
->withRules([
PreferPHPUnitSelfCallRector::class,
])
->withImportNames(importNames: true, importShortClasses: false)
->withSkip([
ClosureToArrowFunctionRector::class,
PreferPHPUnitThisCallRector::class,
])
->withTypeCoverageLevel(0);
5 changes: 1 addition & 4 deletions tests/DocumentEmbedderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,6 @@ public function embedWithSleep(): void
sleep: 3
);

$this->assertSame(
'2024-01-01 00:00:03',
$this->clock->now()->format('Y-m-d H:i:s')
);
self::assertSame('2024-01-01 00:00:03', $this->clock->now()->format('Y-m-d H:i:s'));
}
}
5 changes: 1 addition & 4 deletions tests/Message/Content/ImageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ public function jsonConversionIsWorkingAsExpected(): void
{
$obj = new Image('foo');

self::assertSame(
['type' => 'image_url', 'image_url' => ['url' => 'foo']],
$obj->jsonSerialize(),
);
self::assertSame(['type' => 'image_url', 'image_url' => ['url' => 'foo']], $obj->jsonSerialize());
}
}
5 changes: 1 addition & 4 deletions tests/Message/Content/TextContentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ public function jsonConversionIsWorkingAsExpected(): void
{
$obj = new Text('foo');

self::assertSame(
['type' => 'text', 'text' => 'foo'],
$obj->jsonSerialize(),
);
self::assertSame(['type' => 'text', 'text' => 'foo'], $obj->jsonSerialize());
}
}
23 changes: 10 additions & 13 deletions tests/Message/MessageBagTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,18 +171,15 @@ public function jsonSerialize(): void
$json = json_encode($messageBag);

self::assertJson($json);
self::assertJsonStringEqualsJsonString(
json_encode([
['role' => 'system', 'content' => 'My amazing system prompt.'],
['role' => 'assistant', 'content' => 'It is time to sleep.'],
['role' => 'user', 'content' => 'Hello, world!'],
['role' => 'assistant', 'content' => 'Hello User!'],
['role' => 'user', 'content' => [
['type' => 'text', 'text' => 'My hint for how to analyze an image.'],
['type' => 'image_url', 'image_url' => ['url' => 'http://image-generator.local/my-fancy-image.png']],
]],
]),
$json
);
self::assertJsonStringEqualsJsonString(json_encode([
['role' => 'system', 'content' => 'My amazing system prompt.'],
['role' => 'assistant', 'content' => 'It is time to sleep.'],
['role' => 'user', 'content' => 'Hello, world!'],
['role' => 'assistant', 'content' => 'Hello User!'],
['role' => 'user', 'content' => [
['type' => 'text', 'text' => 'My hint for how to analyze an image.'],
['type' => 'image_url', 'image_url' => ['url' => 'http://image-generator.local/my-fancy-image.png']],
]],
]), $json);
}
}
5 changes: 1 addition & 4 deletions tests/Message/SystemMessageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ public function jsonConversionIsWorkingAsExpected(): void
{
$systemMessage = new SystemMessage('foo');

self::assertSame(
['role' => Role::System, 'content' => 'foo'],
$systemMessage->jsonSerialize(),
);
self::assertSame(['role' => Role::System, 'content' => 'foo'], $systemMessage->jsonSerialize());
}
}
5 changes: 1 addition & 4 deletions tests/Message/ToolCallMessageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ public function jsonConversionIsWorkingAsExpected(): void
$toolCall = new ToolCall('foo', 'bar');
$obj = new ToolCallMessage($toolCall, 'bar');

self::assertSame(
['role' => Role::ToolCall, 'content' => 'bar', 'tool_call_id' => 'foo'],
$obj->jsonSerialize(),
);
self::assertSame(['role' => Role::ToolCall, 'content' => 'bar', 'tool_call_id' => 'foo'], $obj->jsonSerialize());
}
}
17 changes: 7 additions & 10 deletions tests/Response/ToolCallTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,13 @@ public function toolCall(): void
public function toolCallJsonSerialize(): void
{
$toolCall = new ToolCall('id', 'name', ['foo' => 'bar']);
self::assertSame(
[
'id' => 'id',
'type' => 'function',
'function' => [
'name' => 'name',
'arguments' => '{"foo":"bar"}',
],
self::assertSame([
'id' => 'id',
'type' => 'function',
'function' => [
'name' => 'name',
'arguments' => '{"foo":"bar"}',
],
$toolCall->jsonSerialize()
);
], $toolCall->jsonSerialize());
}
}

0 comments on commit c06f8fb

Please sign in to comment.