Skip to content

Commit 6dfcfc6

Browse files
committed
fix
1 parent d477c97 commit 6dfcfc6

23 files changed

Lines changed: 1025 additions & 99 deletions

.env.test.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
QDRANT_URL=127.0.0.1
2+
QDRANT_API_KEY=
3+
QDRANT_CLUSTER_MODE=false

.github/workflows/test.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ jobs:
1919
- php-version: '8.1'
2020
- php-version: '8.2'
2121
- php-version: '8.3'
22+
- php-version: '8.4'
2223
services:
2324
qdrant:
2425
image: qdrant/qdrant

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ vendor/
44
coverage
55
/composer.lock
66
/.idea
7+
.env.test

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
},
1717
"require-dev": {
1818
"phpunit/phpunit": "^10.0",
19-
"mockery/mockery": "^1.5",
19+
"mockery/mockery": "^1.6",
2020
"phpunit/php-code-coverage": "^10.1@dev",
2121
"symfony/http-client": "^6.4.3|^7.1.0",
2222
"nyholm/psr7": "^1.8@dev",

phpunit.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
33
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.2/phpunit.xsd"
4-
bootstrap="vendor/autoload.php"
4+
bootstrap="tests/bootstrap.php"
55
cacheDirectory=".phpunit.cache"
66
executionOrder="depends,defects"
77
beStrictAboutCoverageMetadata="true"

src/Models/MultiVectorStruct.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function getName(): ?string
2929
return array_key_first($this->vectors);
3030
}
3131

32-
public function toSearchArray(string $name = null): array
32+
public function toSearchArray(?string $name = null): array
3333
{
3434
// Throw an error if no name is given
3535
if ($name === null) {

src/Models/VectorStruct.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function getName(): ?string
2626
return $this->name;
2727
}
2828

29-
public function toSearchArray(string $name = null): array
29+
public function toSearchArray(?string $name = null): array
3030
{
3131
if ($this->isNamed()) {
3232
return [

src/Models/VectorStructInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ interface VectorStructInterface
77
/**
88
* Get the name of the vector
99
*
10-
* @return string
10+
* @return string|null
1111
*/
1212
public function getName(): ?string;
1313

@@ -17,7 +17,7 @@ public function getName(): ?string;
1717
* @param string|null $name
1818
* @return array
1919
*/
20-
public function toSearchArray(string $name = null): array;
20+
public function toSearchArray(?string $name = null): array;
2121

2222
/**
2323
* Convert this vector an array for Point and PointsBatch.

tests/Integration/AbstractIntegration.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,15 @@ abstract class AbstractIntegration extends TestCase
2525
protected function setUp(): void
2626
{
2727
parent::setUp();
28-
$config = (new Config('127.0.0.1'));
28+
29+
$qdrantUrl = getenv('QDRANT_URL') ?: '127.0.0.1';
30+
$qdrantApiKey = getenv('QDRANT_API_KEY') ?: '';
31+
32+
$config = new Config($qdrantUrl);
33+
if ($qdrantApiKey) {
34+
$config->setApiKey($qdrantApiKey);
35+
}
36+
2937
$transform = (new Builder())->build($config);
3038
$this->client = new Qdrant($transform);
3139
}
@@ -40,7 +48,7 @@ private static function sampleCollectionOption(): CreateCollection
4048
->addVector(new VectorParams(3, VectorParams::DISTANCE_COSINE), 'text');
4149
}
4250

43-
protected function createCollections($name, CreateCollection $withConfiguration = null): void
51+
protected function createCollections($name, ?CreateCollection $withConfiguration = null): void
4452
{
4553
$this->collections = new Collections($this->client);
4654
$response = $this->collections->setCollectionName($name)

tests/Integration/ClientTest.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@ class ClientTest extends AbstractIntegration
2525
{
2626
public function testClient(): void
2727
{
28-
$config = (new Config('127.0.0.1'));
28+
$qdrantUrl = getenv('QDRANT_URL') ?: '127.0.0.1';
29+
$qdrantApiKey = getenv('QDRANT_API_KEY') ?: null;
30+
31+
$config = (new Config($qdrantUrl));
32+
$config->setApiKey($qdrantApiKey);
2933
$transform = (new Builder())->build($config);
3034
$client = new Qdrant($transform);
3135
$httpFactory = Psr17FactoryDiscovery::findRequestFactory();
@@ -40,7 +44,11 @@ public function testClient(): void
4044
*/
4145
public function testClientService(): void
4246
{
43-
$config = (new Config('127.0.0.1'));
47+
$qdrantUrl = getenv('QDRANT_URL') ?: '127.0.0.1';
48+
$qdrantApiKey = getenv('QDRANT_API_KEY') ?: null;
49+
50+
$config = (new Config($qdrantUrl));
51+
$config->setApiKey($qdrantApiKey);
4452
$transform = (new Builder())->build($config);
4553
$client = new Qdrant($transform);
4654

@@ -50,7 +58,6 @@ public function testClientService(): void
5058

5159
$collections = $client->collections();
5260
$collections->setCollectionName('sample-collection');
53-
$this->assertInstanceOf(Collections::class, $collections);
5461
$this->assertEquals('sample-collection', $collections->getCollectionName());
5562
}
5663
}

0 commit comments

Comments
 (0)