Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions tests/Agents/AgentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ protected function setUp(): void
public function testConstructor(): void
{
$this->assertSame($this->mockAdapter, $this->agent->getAdapter());
$this->assertEquals('', $this->agent->getDescription());
$this->assertEquals([], $this->agent->getInstructions());
$this->assertSame('', $this->agent->getDescription());
$this->assertSame([], $this->agent->getInstructions());
}

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

$this->assertSame($this->agent, $result);
$this->assertEquals($description, $this->agent->getDescription());
$this->assertSame($description, $this->agent->getDescription());
}

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

$this->assertSame($this->agent, $result);
$this->assertEquals($instructions, $this->agent->getInstructions());
$this->assertSame($instructions, $this->agent->getInstructions());
}

public function testAddInstruction(): void
{
// Test adding a single instruction
$result = $this->agent->addInstruction('Instruction 1', 'This is instruction 1');
$this->assertSame($this->agent, $result);
$this->assertEquals([
$this->assertSame([
'Instruction 1' => 'This is instruction 1',
], $this->agent->getInstructions());

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

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

$this->assertSame($this->agent, $result);
$this->assertEquals($description, $this->agent->getDescription());
$this->assertEquals([
$this->assertSame($description, $this->agent->getDescription());
$this->assertSame([
'Instruction 1' => 'Content 1',
'Instruction 2' => 'Content 2',
'Instruction 3' => 'Content 3',
Expand Down Expand Up @@ -132,7 +132,7 @@ public function testEmbeddingDimensions(): void
$embedding = $result['embedding'];
$dimension = count($embedding);

$this->assertEquals($ollama->getEmbeddingDimension(), $dimension);
$this->assertSame($ollama->getEmbeddingDimension(), $dimension);
}
}
}
40 changes: 20 additions & 20 deletions tests/Agents/Conversation/ConversationBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ public function testConstructor(): void
{
$this->assertSame($this->agent, $this->conversation->getAgent());
$this->assertEmpty($this->conversation->getMessages());
$this->assertEquals(0, $this->conversation->getInputTokens());
$this->assertEquals(0, $this->conversation->getOutputTokens());
$this->assertEquals(0, $this->conversation->getTotalTokens());
$this->assertSame(0, $this->conversation->getInputTokens());
$this->assertSame(0, $this->conversation->getOutputTokens());
$this->assertSame(0, $this->conversation->getTotalTokens());
$this->assertIsCallable($this->conversation->getListener());
}

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

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

public function testMultipleMessages(): void
Expand All @@ -90,14 +90,14 @@ public function testMultipleMessages(): void
$messages = $this->conversation->getMessages();
$this->assertCount(3, $messages);

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

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

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

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

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

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

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

public function testTokenCounting(): void
{
$this->conversation->countInputTokens(10);
$this->assertEquals(10, $this->conversation->getInputTokens());
$this->assertSame(10, $this->conversation->getInputTokens());

$this->conversation->countInputTokens(5);
$this->assertEquals(15, $this->conversation->getInputTokens());
$this->assertSame(15, $this->conversation->getInputTokens());

$this->conversation->countOutputTokens(20);
$this->assertEquals(20, $this->conversation->getOutputTokens());
$this->assertSame(20, $this->conversation->getOutputTokens());

$this->conversation->countOutputTokens(10);
$this->assertEquals(30, $this->conversation->getOutputTokens());
$this->assertSame(30, $this->conversation->getOutputTokens());

$this->assertEquals(45, $this->conversation->getTotalTokens());
$this->assertSame(45, $this->conversation->getTotalTokens());
}

public function testListener(): void
Expand Down
12 changes: 6 additions & 6 deletions tests/Agents/Messages/ImageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,44 +38,44 @@ public function testGetContent(): void
{
$message = new Image($this->pngImageData);

$this->assertEquals($this->pngImageData, $message->getContent());
$this->assertSame($this->pngImageData, $message->getContent());
$this->assertIsString($message->getContent());
}

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

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

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

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

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

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

public function testEmptyContent(): void
{
$message = new Image('');

$this->assertEquals('', $message->getContent());
$this->assertSame('', $message->getContent());
$this->assertNull($message->getMimeType());
}

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

$this->assertEquals('not an image', $message->getContent());
$this->assertSame('not an image', $message->getContent());
$this->assertNotNull($message->getMimeType());
$this->assertNotEquals('image/png', $message->getMimeType());
$this->assertNotEquals('image/jpeg', $message->getMimeType());
Expand Down
8 changes: 4 additions & 4 deletions tests/Agents/Messages/TextTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ public function testGetContent(): void
$content = 'Test message content';
$message = new Text($content);

$this->assertEquals($content, $message->getContent());
$this->assertSame($content, $message->getContent());
$this->assertIsString($message->getContent());
}

public function testEmptyContent(): void
{
$message = new Text('');

$this->assertEquals('', $message->getContent());
$this->assertSame('', $message->getContent());
$this->assertIsString($message->getContent());
}

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

$this->assertEquals($content, $message->getContent());
$this->assertSame($content, $message->getContent());
$this->assertStringContainsString("\n", $message->getContent());
}

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

$this->assertEquals($content, $message->getContent());
$this->assertSame($content, $message->getContent());
}
}
10 changes: 5 additions & 5 deletions tests/Agents/Roles/AssistantTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ public function testConstructor(): void

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

$this->assertEquals($id, $assistant->getId());
$this->assertEquals($name, $assistant->getName());
$this->assertSame($id, $assistant->getId());
$this->assertSame($name, $assistant->getName());
}

public function testConstructorWithoutName(): void
Expand All @@ -25,14 +25,14 @@ public function testConstructorWithoutName(): void

$assistant = new Assistant($id);

$this->assertEquals($id, $assistant->getId());
$this->assertEquals('', $assistant->getName());
$this->assertSame($id, $assistant->getId());
$this->assertSame('', $assistant->getName());
}

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

$this->assertEquals(Role::ROLE_ASSISTANT, $assistant->getIdentifier());
$this->assertSame(Role::ROLE_ASSISTANT, $assistant->getIdentifier());
}
}
10 changes: 5 additions & 5 deletions tests/Agents/Roles/UserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ public function testConstructor(): void

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

$this->assertEquals($id, $user->getId());
$this->assertEquals($name, $user->getName());
$this->assertSame($id, $user->getId());
$this->assertSame($name, $user->getName());
}

public function testConstructorWithoutName(): void
Expand All @@ -25,14 +25,14 @@ public function testConstructorWithoutName(): void

$user = new User($id);

$this->assertEquals($id, $user->getId());
$this->assertEquals('', $user->getName());
$this->assertSame($id, $user->getId());
$this->assertSame('', $user->getName());
}

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

$this->assertEquals(Role::ROLE_USER, $user->getIdentifier());
$this->assertSame(Role::ROLE_USER, $user->getIdentifier());
}
}
12 changes: 6 additions & 6 deletions tests/Agents/Schema/SchemaObjectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,25 @@ public function testConstructorAndGetProperties(): void
'age' => ['type' => SchemaObject::TYPE_INTEGER],
];
$object = new SchemaObject($properties);
$this->assertEquals($properties, $object->getProperties());
$this->assertSame($properties, $object->getProperties());
}

public function testGetProperty(): void
{
$object = new SchemaObject([
'id' => ['type' => SchemaObject::TYPE_STRING],
]);
$this->assertEquals(['type' => SchemaObject::TYPE_STRING], $object->getProperty('id'));
$this->assertSame(['type' => SchemaObject::TYPE_STRING], $object->getProperty('id'));
$this->assertNull($object->getProperty('nonexistent'));
}

public function testAddPropertyAndRemoveProperty(): void
{
$object = new SchemaObject();
$object->addProperty('id', ['type' => SchemaObject::TYPE_STRING]);
$this->assertEquals(['id' => ['type' => SchemaObject::TYPE_STRING]], $object->getProperties());
$this->assertSame(['id' => ['type' => SchemaObject::TYPE_STRING]], $object->getProperties());
$object->removeProperty('id');
$this->assertEquals([], $object->getProperties());
$this->assertSame([], $object->getProperties());
}

public function testAddPropertyInvalidType(): void
Expand All @@ -48,7 +48,7 @@ public function testGetNames(): void
'id' => ['type' => SchemaObject::TYPE_STRING],
'age' => ['type' => SchemaObject::TYPE_INTEGER],
]);
$this->assertEquals(['id', 'age'], $object->getNames());
$this->assertSame(['id', 'age'], $object->getNames());
}

public function testGetValidTypes(): void
Expand All @@ -62,6 +62,6 @@ public function testGetValidTypes(): void
SchemaObject::TYPE_OBJECT,
SchemaObject::TYPE_NULL,
];
$this->assertEquals($expected, SchemaObject::getValidTypes());
$this->assertSame($expected, SchemaObject::getValidTypes());
}
}
12 changes: 6 additions & 6 deletions tests/Agents/SchemaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ protected function setUp(): void

public function testConstructorAndGetters(): void
{
$this->assertEquals($this->name, $this->schema->getName());
$this->assertEquals($this->description, $this->schema->getDescription());
$this->assertSame($this->name, $this->schema->getName());
$this->assertSame($this->description, $this->schema->getDescription());
$this->assertSame($this->object, $this->schema->getObject());
$this->assertEquals($this->required, $this->schema->getRequired());
$this->assertSame($this->required, $this->schema->getRequired());
}

public function testToJson(): void
Expand All @@ -63,8 +63,8 @@ public function testToJson(): void
$this->assertArrayHasKey('id', $jsonArray);
$this->assertArrayHasKey('name', $jsonArray);
$this->assertArrayHasKey('age', $jsonArray);
$this->assertEquals('The ID of the user (string)', $jsonArray['id']);
$this->assertEquals('The name of the user (string)', $jsonArray['name']);
$this->assertEquals('The age of the user (integer)', $jsonArray['age']);
$this->assertSame('The ID of the user (string)', $jsonArray['id']);
$this->assertSame('The name of the user (string)', $jsonArray['name']);
$this->assertSame('The age of the user (integer)', $jsonArray['age']);
}
}