Skip to content

Commit a475b23

Browse files
committed
Update tests that construct query validator with Document arrays
1 parent b9bd36f commit a475b23

2 files changed

Lines changed: 19 additions & 3 deletions

File tree

tests/Database/Validator/QueriesTest.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,13 @@ class QueriesTest extends TestCase
9696

9797
public function setUp(): void
9898
{
99-
$this->queryValidator = new QueryValidator($this->collection['attributes']);
99+
// Query validator expects Document[]
100+
$attributes = []; /** @var Document[] $attributes */
101+
foreach ($this->collection['attributes'] as $attribute) {
102+
$attributes[] = new Document($attribute);
103+
}
104+
105+
$this->queryValidator = new QueryValidator($attributes);
100106

101107
$query1 = Query::parse('title.notEqual("Iron Man", "Ant Man")');
102108
$query2 = Query::parse('description.equal("Best movie ever")');

tests/Database/Validator/QueryValidatorTest.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,20 @@
55
use Utopia\Database\Validator\QueryValidator;
66
use PHPUnit\Framework\TestCase;
77
use Utopia\Database\Database;
8+
use Utopia\Database\Document;
89
use Utopia\Database\Query;
910

1011
class QueryValidatorTest extends TestCase
1112
{
1213
/**
13-
* @var array
14+
* @var Document[]
1415
*/
15-
protected $schema = [
16+
protected $schema;
17+
18+
/**
19+
* @var array
20+
*/
21+
protected $attributes = [
1622
[
1723
'$id' => 'title',
1824
'key' => 'title',
@@ -77,6 +83,10 @@ class QueryValidatorTest extends TestCase
7783

7884
public function setUp(): void
7985
{
86+
// Query validator expects Document[]
87+
foreach ($this->attributes as $attribute) {
88+
$this->schema[] = new Document($attribute);
89+
}
8090
}
8191

8292
public function tearDown(): void

0 commit comments

Comments
 (0)