Skip to content

Commit 34e65cc

Browse files
authored
Merge pull request #381 from utopia-php/json-filter-test
Test like on json filter
2 parents 2651f41 + 4b53c0d commit 34e65cc

File tree

2 files changed

+28
-6
lines changed

2 files changed

+28
-6
lines changed

composer.lock

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/e2e/Adapter/Base.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1928,6 +1928,16 @@ public function testArrayAttribute(): void
19281928
array: true
19291929
));
19301930

1931+
$this->assertEquals(true, $database->createAttribute(
1932+
$collection,
1933+
'pref',
1934+
Database::VAR_STRING,
1935+
size: 16384,
1936+
required: false,
1937+
signed: false,
1938+
filters: ['json'],
1939+
));
1940+
19311941
try {
19321942
$database->createDocument($collection, new Document([]));
19331943
$this->fail('Failed to throw exception');
@@ -1981,6 +1991,12 @@ public function testArrayAttribute(): void
19811991
'numbers' => [0, 100, 1000, -1],
19821992
'age' => 41,
19831993
'tv_show' => 'Everybody Loves Raymond',
1994+
'pref' => [
1995+
'fname' => 'Joe',
1996+
'lname' => 'Baiden',
1997+
'age' => 80,
1998+
'male' => true,
1999+
],
19842000
]));
19852001

19862002
$document = $database->getDocument($collection, 'id1');
@@ -2085,6 +2101,12 @@ public function testArrayAttribute(): void
20852101
Query::contains('booleans', [false, true])
20862102
]);
20872103
$this->assertCount(1, $documents);
2104+
2105+
// Regular like query on primitive json string data
2106+
$documents = $database->find($collection, [
2107+
Query::contains('pref', ['Joe'])
2108+
]);
2109+
$this->assertCount(1, $documents);
20882110
}
20892111
}
20902112

0 commit comments

Comments
 (0)