-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathImageTest.php
38 lines (29 loc) · 1.04 KB
/
ImageTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
declare(strict_types=1);
namespace PhpLlm\LlmChain\Tests\Model\Message\Content;
use PhpLlm\LlmChain\Model\Message\Content\Image;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\TestCase;
#[CoversClass(Image::class)]
final class ImageTest extends TestCase
{
#[Test]
public function constructWithValidDataUrl(): void
{
$image = Image::fromDataUrl('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAABKklEQVR42mNk+A8AAwMhIv9n+X');
self::assertStringStartsWith('data:image/png;base64', $image->asDataUrl());
}
#[Test]
public function withValidFile(): void
{
$image = Image::fromFile(dirname(__DIR__, 3).'/Fixture/image.jpg');
self::assertStringStartsWith('data:image/jpeg;base64,', $image->asDataUrl());
}
#[Test]
public function fromBinaryWithInvalidFile(): void
{
$this->expectExceptionMessage('The file "foo.jpg" does not exist or is not readable.');
Image::fromFile('foo.jpg');
}
}