Skip to content

Commit

Permalink
Updated tests and added some extra tests for fields
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert van Lienden committed Mar 4, 2024
1 parent 7e52a67 commit 77686bf
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Domain/Syntax/QueryString.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ public function __construct(string $queryString, string $defaultOperator = self:
{
Assert::oneOf($defaultOperator, [self::OP_OR, self::OP_AND]);

$this->fields = $fields;
$this->queryString = $queryString;
$this->boost = $boost;
$this->defaultOperator = $defaultOperator;
$this->fields = $fields;
}

public function build(): array
Expand Down
20 changes: 20 additions & 0 deletions tests/Unit/Syntax/QueryStringTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public function test_it_builds_the_right_query(): void
'query' => 'test',
'default_operator' => 'OR',
'boost' => 1.0,
'fields' => [],
]
];

Expand All @@ -36,6 +37,25 @@ public function test_it_can_accept_a_custom_default_operator(): void
'query' => 'test',
'default_operator' => 'AND',
'boost' => 1.0,
'fields' => [],
]
];

$query = $subject->build();

self::assertSame($expected, $query);
}

public function test_it_can_accept_fields(): void
{
$subject = new QueryString('test', QueryString::OP_AND, 1.0, ['field1', 'field2']);

$expected = [
'query_string' => [
'query' => 'test',
'default_operator' => 'AND',
'boost' => 1.0,
'fields' => ['field1', 'field2'],
]
];

Expand Down

0 comments on commit 77686bf

Please sign in to comment.