/**
  * Tests toArray method.
  */
 public function testHighlightToArray()
 {
     $highlight = new Highlight([new Field('name')]);
     $highlight->setOrder('test');
     $highlight->setHighlighterType('postings');
     $highlight->setFragmentSize(5);
     $highlight->setNumberOfFragments(5);
     $highlight->setTagsSchema('styled');
     $highlight->setTag('tag', 'class');
     $highlight->setTag('only_tag');
     $result = ['order' => 'test', 'type' => 'postings', 'fragment_size' => 5, 'number_of_fragments' => 5, 'tags_schema' => 'styled', 'post_tags' => ['</tag>', '</only_tag>'], 'pre_tags' => ['<tag class="class">', '<only_tag>'], 'fields' => ['name' => ['matched_fields' => ['name']]]];
     $this->assertEquals($result, $highlight->toArray());
 }
 /**
  * Test highlighted output.
  *
  * The following methods of Highlight class tested:
  *  - setting styled tags schema
  *  - removing field
  *  - setting global highlighting type
  */
 public function testHighlighting2()
 {
     /**
      * @var Repository $repository
      * @var TermQuery  $termQuery
      */
     list($repository, $termQuery) = $this->buildRepositoryAndTerm();
     $highlight = new Highlight();
     $highlight->setTagsSchema('styled')->add((new Field('title'))->setForceSource(true))->add(new Field('title'))->add(new Field('description'));
     $highlight->remove('description');
     $highlight->setHighlighterType(Highlight::TYPE_PLAIN);
     $results = $this->executeHighlight($repository, $termQuery, $highlight);
     $product = $results['hits']['hits'][0];
     $this->assertStringStartsWith('<em class="hlt1">', $product['highlight']['title'][0]);
     $this->assertArrayNotHasKey('description', $product['highlight']);
 }