Skip to content

Commit cefe7c6

Browse files
committed
Fix unit tests
1 parent 18926bf commit cefe7c6

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

bin/tasks/relationships.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ function benchmarkSingle(Database $database): array
356356

357357
foreach ($collections as $collection) {
358358
// Fetch one document ID to use (skip relationships to avoid infinite recursion)
359-
$docs = $database->skipRelationships(fn() => $database->findOne($collection));
359+
$docs = $database->skipRelationships(fn () => $database->findOne($collection));
360360
$id = $docs->getId();
361361

362362
$start = microtime(true);

src/Database/Validator/Query/Filter.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,11 @@ public function isValid($value): bool
330330
}
331331
}
332332

333+
public function getMaxValuesCount(): int
334+
{
335+
return $this->maxValuesCount;
336+
}
337+
333338
public function getMethodType(): string
334339
{
335340
return self::METHOD_TYPE_FILTER;

tests/unit/Validator/Query/FilterTest.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,11 @@
66
use Utopia\Database\Database;
77
use Utopia\Database\Document;
88
use Utopia\Database\Query;
9-
use Utopia\Database\Validator\Query\Base;
109
use Utopia\Database\Validator\Query\Filter;
1110

1211
class FilterTest extends TestCase
1312
{
14-
protected Base|null $validator = null;
13+
protected Filter|null $validator = null;
1514

1615
/**
1716
* @throws \Utopia\Database\Exception
@@ -45,7 +44,10 @@ public function setUp(): void
4544
]),
4645
];
4746

48-
$this->validator = new Filter($attributes, Database::VAR_INTEGER);
47+
$this->validator = new Filter(
48+
$attributes,
49+
Database::VAR_INTEGER
50+
);
4951
}
5052

5153
public function testSuccess(): void
@@ -106,13 +108,14 @@ public function testEmptyValues(): void
106108

107109
public function testMaxValuesCount(): void
108110
{
111+
$max = $this->validator->getMaxValuesCount();
109112
$values = [];
110-
for ($i = 1; $i <= 200; $i++) {
113+
for ($i = 1; $i <= $max + 1; $i++) {
111114
$values[] = $i;
112115
}
113116

114117
$this->assertFalse($this->validator->isValid(Query::equal('integer', $values)));
115-
$this->assertEquals('Query on attribute has greater than 100 values: integer', $this->validator->getDescription());
118+
$this->assertEquals('Query on attribute has greater than '.$max.' values: integer', $this->validator->getDescription());
116119
}
117120

118121
public function testNotContains(): void

0 commit comments

Comments
 (0)