Skip to content

Commit a31afce

Browse files
Refactor: assertions
- replace assertEquals with assertSame
1 parent 7bbc77d commit a31afce

File tree

8 files changed

+62
-62
lines changed

8 files changed

+62
-62
lines changed

tests/Agents/AgentTest.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ protected function setUp(): void
2424
public function testConstructor(): void
2525
{
2626
$this->assertSame($this->mockAdapter, $this->agent->getAdapter());
27-
$this->assertEquals('', $this->agent->getDescription());
28-
$this->assertEquals([], $this->agent->getInstructions());
27+
$this->assertSame('', $this->agent->getDescription());
28+
$this->assertSame([], $this->agent->getInstructions());
2929
}
3030

3131
public function testSetDescription(): void
@@ -35,7 +35,7 @@ public function testSetDescription(): void
3535
$result = $this->agent->setDescription($description);
3636

3737
$this->assertSame($this->agent, $result);
38-
$this->assertEquals($description, $this->agent->getDescription());
38+
$this->assertSame($description, $this->agent->getDescription());
3939
}
4040

4141
public function testSetInstructions(): void
@@ -48,27 +48,27 @@ public function testSetInstructions(): void
4848
$result = $this->agent->setInstructions($instructions);
4949

5050
$this->assertSame($this->agent, $result);
51-
$this->assertEquals($instructions, $this->agent->getInstructions());
51+
$this->assertSame($instructions, $this->agent->getInstructions());
5252
}
5353

5454
public function testAddInstruction(): void
5555
{
5656
// Test adding a single instruction
5757
$result = $this->agent->addInstruction('Instruction 1', 'This is instruction 1');
5858
$this->assertSame($this->agent, $result);
59-
$this->assertEquals([
59+
$this->assertSame([
6060
'Instruction 1' => 'This is instruction 1',
6161
], $this->agent->getInstructions());
6262

6363
// Test adding a duplicate instruction (should update the content)
6464
$this->agent->addInstruction('Instruction 1', 'Updated content');
65-
$this->assertEquals([
65+
$this->assertSame([
6666
'Instruction 1' => 'Updated content',
6767
], $this->agent->getInstructions());
6868

6969
// Test adding a second instruction
7070
$this->agent->addInstruction('Instruction 2', 'This is instruction 2');
71-
$this->assertEquals([
71+
$this->assertSame([
7272
'Instruction 1' => 'Updated content',
7373
'Instruction 2' => 'This is instruction 2',
7474
], $this->agent->getInstructions());
@@ -88,8 +88,8 @@ public function testFluentInterface(): void
8888
->addInstruction('Instruction 3', 'Content 3');
8989

9090
$this->assertSame($this->agent, $result);
91-
$this->assertEquals($description, $this->agent->getDescription());
92-
$this->assertEquals([
91+
$this->assertSame($description, $this->agent->getDescription());
92+
$this->assertSame([
9393
'Instruction 1' => 'Content 1',
9494
'Instruction 2' => 'Content 2',
9595
'Instruction 3' => 'Content 3',
@@ -132,7 +132,7 @@ public function testEmbeddingDimensions(): void
132132
$embedding = $result['embedding'];
133133
$dimension = count($embedding);
134134

135-
$this->assertEquals($ollama->getEmbeddingDimension(), $dimension);
135+
$this->assertSame($ollama->getEmbeddingDimension(), $dimension);
136136
}
137137
}
138138
}

tests/Agents/Conversation/ConversationBase.php

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ public function testConstructor(): void
5656
{
5757
$this->assertSame($this->agent, $this->conversation->getAgent());
5858
$this->assertEmpty($this->conversation->getMessages());
59-
$this->assertEquals(0, $this->conversation->getInputTokens());
60-
$this->assertEquals(0, $this->conversation->getOutputTokens());
61-
$this->assertEquals(0, $this->conversation->getTotalTokens());
59+
$this->assertSame(0, $this->conversation->getInputTokens());
60+
$this->assertSame(0, $this->conversation->getOutputTokens());
61+
$this->assertSame(0, $this->conversation->getTotalTokens());
6262
$this->assertIsCallable($this->conversation->getListener());
6363
}
6464

@@ -73,8 +73,8 @@ public function testMessage(): void
7373
$this->assertCount(1, $this->conversation->getMessages());
7474

7575
$firstMessage = $this->conversation->getMessages()[0];
76-
$this->assertEquals(Role::ROLE_USER, $firstMessage->getRole());
77-
$this->assertEquals('Hello, AI!', $firstMessage->getContent());
76+
$this->assertSame(Role::ROLE_USER, $firstMessage->getRole());
77+
$this->assertSame('Hello, AI!', $firstMessage->getContent());
7878
}
7979

8080
public function testMultipleMessages(): void
@@ -90,14 +90,14 @@ public function testMultipleMessages(): void
9090
$messages = $this->conversation->getMessages();
9191
$this->assertCount(3, $messages);
9292

93-
$this->assertEquals(Role::ROLE_USER, $messages[0]->getRole());
94-
$this->assertEquals('Hello', $messages[0]->getContent());
93+
$this->assertSame(Role::ROLE_USER, $messages[0]->getRole());
94+
$this->assertSame('Hello', $messages[0]->getContent());
9595

96-
$this->assertEquals(Role::ROLE_ASSISTANT, $messages[1]->getRole());
97-
$this->assertEquals('Hi there!', $messages[1]->getContent());
96+
$this->assertSame(Role::ROLE_ASSISTANT, $messages[1]->getRole());
97+
$this->assertSame('Hi there!', $messages[1]->getContent());
9898

99-
$this->assertEquals(Role::ROLE_USER, $messages[2]->getRole());
100-
$this->assertEquals('How are you?', $messages[2]->getContent());
99+
$this->assertSame(Role::ROLE_USER, $messages[2]->getRole());
100+
$this->assertSame('How are you?', $messages[2]->getContent());
101101
}
102102

103103
public function testSend(): void
@@ -112,11 +112,11 @@ public function testSend(): void
112112
// Verify the response was added to conversation
113113
$conversationMessages = $this->conversation->getMessages();
114114
$this->assertNotEmpty($conversationMessages);
115-
$this->assertEquals(Role::ROLE_USER, $conversationMessages[0]->getRole());
116-
$this->assertEquals('Hello', $conversationMessages[0]->getContent());
115+
$this->assertSame(Role::ROLE_USER, $conversationMessages[0]->getRole());
116+
$this->assertSame('Hello', $conversationMessages[0]->getContent());
117117

118118
// Verify AI response
119-
$this->assertEquals(Role::ROLE_ASSISTANT, $conversationMessages[1]->getRole());
119+
$this->assertSame(Role::ROLE_ASSISTANT, $conversationMessages[1]->getRole());
120120
$this->assertNotEmpty($conversationMessages[1]->getContent());
121121
}
122122

@@ -164,24 +164,24 @@ public function testSchema(): void
164164
$this->assertIsString($json['unit'], 'Unit must be a string');
165165

166166
$this->assertStringContainsString('San Francisco', $json['location']);
167-
$this->assertEquals('celsius', $json['unit']);
167+
$this->assertSame('celsius', $json['unit']);
168168
}
169169

170170
public function testTokenCounting(): void
171171
{
172172
$this->conversation->countInputTokens(10);
173-
$this->assertEquals(10, $this->conversation->getInputTokens());
173+
$this->assertSame(10, $this->conversation->getInputTokens());
174174

175175
$this->conversation->countInputTokens(5);
176-
$this->assertEquals(15, $this->conversation->getInputTokens());
176+
$this->assertSame(15, $this->conversation->getInputTokens());
177177

178178
$this->conversation->countOutputTokens(20);
179-
$this->assertEquals(20, $this->conversation->getOutputTokens());
179+
$this->assertSame(20, $this->conversation->getOutputTokens());
180180

181181
$this->conversation->countOutputTokens(10);
182-
$this->assertEquals(30, $this->conversation->getOutputTokens());
182+
$this->assertSame(30, $this->conversation->getOutputTokens());
183183

184-
$this->assertEquals(45, $this->conversation->getTotalTokens());
184+
$this->assertSame(45, $this->conversation->getTotalTokens());
185185
}
186186

187187
public function testListener(): void

tests/Agents/Messages/ImageTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,44 +38,44 @@ public function testGetContent(): void
3838
{
3939
$message = new Image($this->pngImageData);
4040

41-
$this->assertEquals($this->pngImageData, $message->getContent());
41+
$this->assertSame($this->pngImageData, $message->getContent());
4242
$this->assertIsString($message->getContent());
4343
}
4444

4545
public function testGetMimeTypePNG(): void
4646
{
4747
$message = new Image($this->pngImageData);
4848

49-
$this->assertEquals('image/png', $message->getMimeType());
49+
$this->assertSame('image/png', $message->getMimeType());
5050
}
5151

5252
public function testGetMimeTypeJPEG(): void
5353
{
5454
$message = new Image($this->jpegImageData);
5555

56-
$this->assertEquals('image/jpeg', $message->getMimeType());
56+
$this->assertSame('image/jpeg', $message->getMimeType());
5757
}
5858

5959
public function testGetMimeTypeGIF(): void
6060
{
6161
$message = new Image($this->gifImageData);
6262

63-
$this->assertEquals('image/gif', $message->getMimeType());
63+
$this->assertSame('image/gif', $message->getMimeType());
6464
}
6565

6666
public function testEmptyContent(): void
6767
{
6868
$message = new Image('');
6969

70-
$this->assertEquals('', $message->getContent());
70+
$this->assertSame('', $message->getContent());
7171
$this->assertNull($message->getMimeType());
7272
}
7373

7474
public function testInvalidImageData(): void
7575
{
7676
$message = new Image('not an image');
7777

78-
$this->assertEquals('not an image', $message->getContent());
78+
$this->assertSame('not an image', $message->getContent());
7979
$this->assertNotNull($message->getMimeType());
8080
$this->assertNotEquals('image/png', $message->getMimeType());
8181
$this->assertNotEquals('image/jpeg', $message->getMimeType());

tests/Agents/Messages/TextTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ public function testGetContent(): void
2222
$content = 'Test message content';
2323
$message = new Text($content);
2424

25-
$this->assertEquals($content, $message->getContent());
25+
$this->assertSame($content, $message->getContent());
2626
$this->assertIsString($message->getContent());
2727
}
2828

2929
public function testEmptyContent(): void
3030
{
3131
$message = new Text('');
3232

33-
$this->assertEquals('', $message->getContent());
33+
$this->assertSame('', $message->getContent());
3434
$this->assertIsString($message->getContent());
3535
}
3636

@@ -39,7 +39,7 @@ public function testMultilineContent(): void
3939
$content = "Line 1\nLine 2\nLine 3";
4040
$message = new Text($content);
4141

42-
$this->assertEquals($content, $message->getContent());
42+
$this->assertSame($content, $message->getContent());
4343
$this->assertStringContainsString("\n", $message->getContent());
4444
}
4545

@@ -48,6 +48,6 @@ public function testSpecialCharacters(): void
4848
$content = 'Special chars: !@#$%^&*()_+ 😀 🌟';
4949
$message = new Text($content);
5050

51-
$this->assertEquals($content, $message->getContent());
51+
$this->assertSame($content, $message->getContent());
5252
}
5353
}

tests/Agents/Roles/AssistantTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ public function testConstructor(): void
1515

1616
$assistant = new Assistant($id, $name);
1717

18-
$this->assertEquals($id, $assistant->getId());
19-
$this->assertEquals($name, $assistant->getName());
18+
$this->assertSame($id, $assistant->getId());
19+
$this->assertSame($name, $assistant->getName());
2020
}
2121

2222
public function testConstructorWithoutName(): void
@@ -25,14 +25,14 @@ public function testConstructorWithoutName(): void
2525

2626
$assistant = new Assistant($id);
2727

28-
$this->assertEquals($id, $assistant->getId());
29-
$this->assertEquals('', $assistant->getName());
28+
$this->assertSame($id, $assistant->getId());
29+
$this->assertSame('', $assistant->getName());
3030
}
3131

3232
public function testGetIdentifier(): void
3333
{
3434
$assistant = new Assistant('test-id');
3535

36-
$this->assertEquals(Role::ROLE_ASSISTANT, $assistant->getIdentifier());
36+
$this->assertSame(Role::ROLE_ASSISTANT, $assistant->getIdentifier());
3737
}
3838
}

tests/Agents/Roles/UserTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ public function testConstructor(): void
1515

1616
$user = new User($id, $name);
1717

18-
$this->assertEquals($id, $user->getId());
19-
$this->assertEquals($name, $user->getName());
18+
$this->assertSame($id, $user->getId());
19+
$this->assertSame($name, $user->getName());
2020
}
2121

2222
public function testConstructorWithoutName(): void
@@ -25,14 +25,14 @@ public function testConstructorWithoutName(): void
2525

2626
$user = new User($id);
2727

28-
$this->assertEquals($id, $user->getId());
29-
$this->assertEquals('', $user->getName());
28+
$this->assertSame($id, $user->getId());
29+
$this->assertSame('', $user->getName());
3030
}
3131

3232
public function testGetIdentifier(): void
3333
{
3434
$user = new User('test-id');
3535

36-
$this->assertEquals(Role::ROLE_USER, $user->getIdentifier());
36+
$this->assertSame(Role::ROLE_USER, $user->getIdentifier());
3737
}
3838
}

tests/Agents/Schema/SchemaObjectTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,25 @@ public function testConstructorAndGetProperties(): void
1414
'age' => ['type' => SchemaObject::TYPE_INTEGER],
1515
];
1616
$object = new SchemaObject($properties);
17-
$this->assertEquals($properties, $object->getProperties());
17+
$this->assertSame($properties, $object->getProperties());
1818
}
1919

2020
public function testGetProperty(): void
2121
{
2222
$object = new SchemaObject([
2323
'id' => ['type' => SchemaObject::TYPE_STRING],
2424
]);
25-
$this->assertEquals(['type' => SchemaObject::TYPE_STRING], $object->getProperty('id'));
25+
$this->assertSame(['type' => SchemaObject::TYPE_STRING], $object->getProperty('id'));
2626
$this->assertNull($object->getProperty('nonexistent'));
2727
}
2828

2929
public function testAddPropertyAndRemoveProperty(): void
3030
{
3131
$object = new SchemaObject();
3232
$object->addProperty('id', ['type' => SchemaObject::TYPE_STRING]);
33-
$this->assertEquals(['id' => ['type' => SchemaObject::TYPE_STRING]], $object->getProperties());
33+
$this->assertSame(['id' => ['type' => SchemaObject::TYPE_STRING]], $object->getProperties());
3434
$object->removeProperty('id');
35-
$this->assertEquals([], $object->getProperties());
35+
$this->assertSame([], $object->getProperties());
3636
}
3737

3838
public function testAddPropertyInvalidType(): void
@@ -48,7 +48,7 @@ public function testGetNames(): void
4848
'id' => ['type' => SchemaObject::TYPE_STRING],
4949
'age' => ['type' => SchemaObject::TYPE_INTEGER],
5050
]);
51-
$this->assertEquals(['id', 'age'], $object->getNames());
51+
$this->assertSame(['id', 'age'], $object->getNames());
5252
}
5353

5454
public function testGetValidTypes(): void
@@ -62,6 +62,6 @@ public function testGetValidTypes(): void
6262
SchemaObject::TYPE_OBJECT,
6363
SchemaObject::TYPE_NULL,
6464
];
65-
$this->assertEquals($expected, SchemaObject::getValidTypes());
65+
$this->assertSame($expected, SchemaObject::getValidTypes());
6666
}
6767
}

tests/Agents/SchemaTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ protected function setUp(): void
4747

4848
public function testConstructorAndGetters(): void
4949
{
50-
$this->assertEquals($this->name, $this->schema->getName());
51-
$this->assertEquals($this->description, $this->schema->getDescription());
50+
$this->assertSame($this->name, $this->schema->getName());
51+
$this->assertSame($this->description, $this->schema->getDescription());
5252
$this->assertSame($this->object, $this->schema->getObject());
53-
$this->assertEquals($this->required, $this->schema->getRequired());
53+
$this->assertSame($this->required, $this->schema->getRequired());
5454
}
5555

5656
public function testToJson(): void
@@ -63,8 +63,8 @@ public function testToJson(): void
6363
$this->assertArrayHasKey('id', $jsonArray);
6464
$this->assertArrayHasKey('name', $jsonArray);
6565
$this->assertArrayHasKey('age', $jsonArray);
66-
$this->assertEquals('The ID of the user (string)', $jsonArray['id']);
67-
$this->assertEquals('The name of the user (string)', $jsonArray['name']);
68-
$this->assertEquals('The age of the user (integer)', $jsonArray['age']);
66+
$this->assertSame('The ID of the user (string)', $jsonArray['id']);
67+
$this->assertSame('The name of the user (string)', $jsonArray['name']);
68+
$this->assertSame('The age of the user (integer)', $jsonArray['age']);
6969
}
7070
}

0 commit comments

Comments
 (0)