Skip to content

Commit 5df789b

Browse files
committed
minor #441 [Platform] Add comprehensive unit tests for VectorResult (OskarStark)
This PR was merged into the main branch. Discussion ---------- [Platform] Add comprehensive unit tests for `VectorResult` | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | Docs? | no | Issues | -- | License | MIT Commits ------- 2abd7f0 [Platform] Add comprehensive unit tests for VectorResult
2 parents 7b4314d + 2abd7f0 commit 5df789b

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\AI\Platform\Tests\Result;
13+
14+
use PHPUnit\Framework\Attributes\CoversClass;
15+
use PHPUnit\Framework\Attributes\Small;
16+
use PHPUnit\Framework\TestCase;
17+
use Symfony\AI\Platform\Result\VectorResult;
18+
use Symfony\AI\Platform\Vector\Vector;
19+
20+
/**
21+
* @author Oskar Stark <[email protected]>
22+
*/
23+
#[CoversClass(VectorResult::class)]
24+
#[Small]
25+
final class VectorResultTest extends TestCase
26+
{
27+
public function testGetContentWithSingleVector()
28+
{
29+
$vector = new Vector([0.1, 0.2, 0.3]);
30+
$result = new VectorResult($vector);
31+
32+
$this->assertSame([$vector], $result->getContent());
33+
}
34+
35+
public function testGetContentWithMultipleVectors()
36+
{
37+
$vector1 = new Vector([0.1, 0.2, 0.3]);
38+
$vector2 = new Vector([0.4, 0.5, 0.6]);
39+
$vector3 = new Vector([0.7, 0.8, 0.9]);
40+
41+
$result = new VectorResult($vector1, $vector2, $vector3);
42+
43+
$expected = [$vector1, $vector2, $vector3];
44+
$this->assertSame($expected, $result->getContent());
45+
}
46+
47+
public function testGetContentWithNoVectors()
48+
{
49+
$result = new VectorResult();
50+
51+
$this->assertSame([], $result->getContent());
52+
}
53+
54+
public function testConstructorAcceptsVariadicVectors()
55+
{
56+
$vectors = [
57+
new Vector([0.1, 0.2]),
58+
new Vector([0.3, 0.4]),
59+
new Vector([0.5, 0.6]),
60+
];
61+
62+
$result = new VectorResult(...$vectors);
63+
64+
$this->assertSame($vectors, $result->getContent());
65+
}
66+
}

0 commit comments

Comments
 (0)