Skip to content

Commit

Permalink
Up some getters and setters tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Firesphere committed Oct 17, 2023
1 parent 390a3dd commit a07065f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Traits/IndexTraits/BaseIndexTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ public function getFacetFields()
*/
public function addFilterField($filterField): self
{
$this->filterFields[] = $filterField;
$this->addFulltextField($filterField);

return $this;
Expand Down
13 changes: 13 additions & 0 deletions tests/unit/Indexes/ElasticIndexTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,15 @@ public function testAddSetGet()
$index->setSortFields(['Blub', 'Blubblub']);
$this->assertContains('Blubblub', $index->getFullTextFields());

$index->setFilterFields(['FieldA', 'FieldB']);

$this->assertContains('FieldA', $index->getFilterFields());
$this->assertContains('FieldA', $index->getFulltextFields());
$index->addFilterField('FieldC');
$this->assertContains('FieldC', $index->getFilterFields());
$this->assertContains('FieldC', $index->getFulltextFields());


// No facets set yet
$this->assertEquals([], $index->getFacetFields());

Expand All @@ -87,6 +96,10 @@ public function testAddSetGet()
$this->assertContains('MyContent', $index->getFulltextFields());
$index->addFacetField('Field1', ['Field' => 'Field1']);
$this->assertArrayHasKey('Field1', $index->getFacetFields());

$index->setStoredFields(['Title', 'Content', 'FieldD']);
$this->assertContains('FieldD', $index->getFulltextFields);
$this->assertEquals(['Title', 'Content', 'FieldD']);
}

public function testAddAllFields()
Expand Down

0 comments on commit a07065f

Please sign in to comment.