mirror of
https://github.com/symfony/ai-platform.git
synced 2026-03-23 23:12:22 +01:00
70 lines
2.1 KiB
PHP
70 lines
2.1 KiB
PHP
<?php
|
|
|
|
/*
|
|
* This file is part of the Symfony package.
|
|
*
|
|
* (c) Fabien Potencier <fabien@symfony.com>
|
|
*
|
|
* For the full copyright and license information, please view the LICENSE
|
|
* file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace Symfony\AI\Platform\Tests\Message;
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
use Symfony\AI\Platform\Message\Role;
|
|
use Symfony\AI\Platform\Message\SystemMessage;
|
|
use Symfony\AI\Platform\Tests\Helper\UuidAssertionTrait;
|
|
use Symfony\Component\Uid\AbstractUid;
|
|
use Symfony\Component\Uid\TimeBasedUidInterface;
|
|
use Symfony\Component\Uid\UuidV7;
|
|
|
|
final class SystemMessageTest extends TestCase
|
|
{
|
|
use UuidAssertionTrait;
|
|
|
|
public function testConstructionIsPossible()
|
|
{
|
|
$message = new SystemMessage('foo');
|
|
|
|
$this->assertSame(Role::System, $message->getRole());
|
|
$this->assertSame('foo', $message->getContent());
|
|
}
|
|
|
|
public function testMessageHasUid()
|
|
{
|
|
$message = new SystemMessage('foo');
|
|
|
|
$this->assertInstanceOf(UuidV7::class, $message->getId());
|
|
}
|
|
|
|
public function testDifferentMessagesHaveDifferentUids()
|
|
{
|
|
$message1 = new SystemMessage('foo');
|
|
$message2 = new SystemMessage('bar');
|
|
|
|
$this->assertNotSame($message1->getId()->toRfc4122(), $message2->getId()->toRfc4122());
|
|
$this->assertIsUuidV7($message1->getId()->toRfc4122());
|
|
$this->assertIsUuidV7($message2->getId()->toRfc4122());
|
|
}
|
|
|
|
public function testSameMessagesHaveDifferentUids()
|
|
{
|
|
$message1 = new SystemMessage('foo');
|
|
$message2 = new SystemMessage('foo');
|
|
|
|
$this->assertNotSame($message1->getId()->toRfc4122(), $message2->getId()->toRfc4122());
|
|
$this->assertIsUuidV7($message1->getId()->toRfc4122());
|
|
$this->assertIsUuidV7($message2->getId()->toRfc4122());
|
|
}
|
|
|
|
public function testMessageIdImplementsRequiredInterfaces()
|
|
{
|
|
$message = new SystemMessage('test');
|
|
|
|
$this->assertInstanceOf(AbstractUid::class, $message->getId());
|
|
$this->assertInstanceOf(TimeBasedUidInterface::class, $message->getId());
|
|
$this->assertInstanceOf(UuidV7::class, $message->getId());
|
|
}
|
|
}
|