Skip to content

Commit 46c3a43

Browse files
committed
Add unit tests for Point class
1 parent 7495602 commit 46c3a43

1 file changed

Lines changed: 55 additions & 0 deletions

File tree

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?php
2+
/**
3+
* @since Mar 2023
4+
* @author Haydar KULEKCI <haydarkulekci@gmail.com>
5+
*/
6+
7+
namespace Qdrant\Tests\Unit\Models\Request;
8+
9+
use PHPUnit\Framework\TestCase;
10+
use Qdrant\Models\Request\Point;
11+
use Qdrant\Models\VectorStruct;
12+
13+
class PointTest extends TestCase
14+
{
15+
public function testValidBasic(): void
16+
{
17+
$point = new Point(
18+
'1',
19+
new VectorStruct([1, 2, 3])
20+
);
21+
22+
$this->assertEquals([
23+
'id' => '1',
24+
'vector' => [1, 2, 3]
25+
], $point->toArray());
26+
}
27+
28+
public function testValidBasicWithArrayVector(): void
29+
{
30+
$point = new Point(
31+
'1',
32+
[1, 2, 3]
33+
);
34+
35+
$this->assertEquals([
36+
'id' => '1',
37+
'vector' => [1, 2, 3]
38+
], $point->toArray());
39+
}
40+
41+
public function testValidBasicWithPayload(): void
42+
{
43+
$point = new Point(
44+
'1',
45+
[1, 2, 3],
46+
['foo' => 'bar']
47+
);
48+
49+
$this->assertEquals([
50+
'id' => '1',
51+
'vector' => [1, 2, 3],
52+
'payload' => ['foo' => 'bar']
53+
], $point->toArray());
54+
}
55+
}

0 commit comments

Comments
 (0)