Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new test case for equal boolean field #277

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions packages/seal/src/Testing/AbstractSearcherTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,50 @@ public function testEqualCondition(): void
}
}

public function testEqualConditionWithBoolean(): void
{
$documents = TestingHelper::createComplexFixtures();

$schema = self::getSchema();

foreach ($documents as $document) {
self::$taskHelper->tasks[] = self::$indexer->save(
$schema->indexes[TestingHelper::INDEX_COMPLEX],
$document,
['return_slow_promise_result' => true],
);
}
self::$taskHelper->waitForAll();

$search = new SearchBuilder($schema, self::$searcher);
$search->addIndex(TestingHelper::INDEX_COMPLEX);
$search->addFilter(new Condition\EqualCondition('isSpecial', true));

$expectedDocumentsVariantA = [
$documents[0],
];
$expectedDocumentsVariantB = [
$documents[0],
];

$loadedDocuments = [...$search->getResult()];
$this->assertCount(1, $loadedDocuments);

$this->assertTrue(
$expectedDocumentsVariantA === $loadedDocuments
|| $expectedDocumentsVariantB === $loadedDocuments,
'Not correct documents where found.',
);

foreach ($documents as $document) {
self::$taskHelper->tasks[] = self::$indexer->delete(
$schema->indexes[TestingHelper::INDEX_COMPLEX],
$document['uuid'],
['return_slow_promise_result' => true],
);
}
}

public function testMultiEqualCondition(): void
{
$documents = TestingHelper::createComplexFixtures();
Expand Down
3 changes: 3 additions & 0 deletions packages/seal/src/Testing/TestingHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public static function createSchema(): Schema
'created' => new Field\DateTimeField('created', filterable: true, sortable: true),
'commentsCount' => new Field\IntegerField('commentsCount', filterable: true, sortable: true),
'rating' => new Field\FloatField('rating', filterable: true, sortable: true),
'isSpecial' => new Field\BooleanField('isSpecial', filterable: true),
'comments' => new Field\ObjectField('comments', [
'email' => new Field\TextField('email', searchable: false),
'text' => new Field\TextField('text'),
Expand Down Expand Up @@ -144,6 +145,7 @@ public static function createComplexFixtures(): array
'created' => '2022-01-24T12:00:00+01:00',
'commentsCount' => 2,
'rating' => 3.5,
'isSpecial' => true,
'comments' => [
[
'email' => 'admin.nonesearchablefield@localhost',
Expand Down Expand Up @@ -171,6 +173,7 @@ public static function createComplexFixtures(): array
'created' => '2022-12-26T12:00:00+01:00',
'commentsCount' => 0,
'rating' => 2.5,
'isSpecial' => false,
'comments' => [],
'tags' => ['UI', 'UX'],
'categoryIds' => [2, 3],
Expand Down
3 changes: 3 additions & 0 deletions packages/seal/tests/Marshaller/FlattenMarshallerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ public static function provideData(): \Generator
'created' => '2022-01-24T12:00:00+01:00',
'commentsCount' => 2,
'rating' => 3.5,
'isSpecial' => true,
'comments' => [
[
'email' => 'admin.nonesearchablefield@localhost',
Expand Down Expand Up @@ -126,6 +127,7 @@ public static function provideData(): \Generator
'created' => '2022-01-24T12:00:00+01:00',
'commentsCount' => 2,
'rating' => 3.5,
'isSpecial' => true,
'comments.email' => ['admin.nonesearchablefield@localhost', 'example.nonesearchablefield@localhost'],
'comments.text' => ['Awesome blog!', 'Like this blog!'],
'tags' => ['Tech', 'UI'],
Expand Down Expand Up @@ -161,6 +163,7 @@ public static function provideData(): \Generator
'created' => new Field\DateTimeField('created', filterable: true, sortable: true),
'commentsCount' => new Field\IntegerField('commentsCount', searchable: false, filterable: true, sortable: true),
'rating' => new Field\FloatField('rating', searchable: false, filterable: true, sortable: true),
'isSpecial' => new Field\BooleanField('rating', searchable: false, filterable: true),
'comments' => new Field\ObjectField('comments', [
'email' => new Field\TextField('email', searchable: false),
'text' => new Field\TextField('text'),
Expand Down
1 change: 1 addition & 0 deletions packages/seal/tests/Marshaller/MarshallerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ private function getRawDocument(bool $dateAsInteger = false): array
'created' => $dateAsInteger ? 1_643_022_000 : '2022-01-24T12:00:00+01:00',
'commentsCount' => 2,
'rating' => 3.5,
'isSpecial' => true,
'comments' => [
[
'email' => 'admin.nonesearchablefield@localhost',
Expand Down
Loading