Exemplo n.º 1
0
 protected function getResultCollection($word)
 {
     $keywords = new Keywords();
     $keywords->addKeyword($word);
     $query = new Query($keywords);
     $query->setIndex('produtoIndex');
     $collection = Search::getInstance()->findByQuery($query);
     return $collection;
 }
Exemplo n.º 2
0
 /**
  * @dataProvider      dataProviderFrasesValidas
  */
 public function testSucessoAoPesquisarComFrases($string)
 {
     if (!$this->hasHost()) {
         return $this->markTestSkipped();
     }
     $keywords = new Keywords();
     $keywords->readString($string);
     $query = new Query($keywords);
     $query->setIndex('produtoIndex');
     $collection = Search::getInstance()->findByQuery($query);
     $this->assertInstanceOf('\\Gpupo\\Search\\Result\\Collection', $collection);
     $this->assertGreaterThan(5, $collection->getTotal());
     $this->assertGreaterThan(5, $collection->getTotalFound());
     $this->assertInternalType('integer', $collection->getTotal());
     $this->assertInternalType('integer', $collection->getTotalFound());
 }
Exemplo n.º 3
0
 public function testPesquisaComPalavrasForaDeOrdem()
 {
     $keywords = new Keywords();
     $keywords->addKeyword('shampoo');
     $keywords->addKeyword('condicionador');
     $query = new Query($keywords);
     $query->setIndex('produtoIndex');
     if (!$this->hasHost()) {
         return $this->markTestSkipped();
     }
     $total['mode_1'] = Search::getInstance()->findByQuery($query)->getTotal();
     //Mode 2
     $keywords = new Keywords();
     $keywords->readString('shampoo condicionador');
     $query = new Query($keywords);
     $query->setIndex('produtoIndex');
     $total['mode_2'] = Search::getInstance()->findByQuery($query)->getTotal();
     //Mode 3
     $keywords = new Keywords();
     $keywords->readString('condicionador shampoo');
     $query = new Query($keywords);
     $query->setIndex('produtoIndex');
     $total['mode_3'] = Search::getInstance()->findByQuery($query)->getTotal();
     $this->assertEquals($total['mode_1'], $total['mode_2']);
     $this->assertEquals($total['mode_1'], $total['mode_3']);
     $this->assertEquals($total['mode_2'], $total['mode_3']);
 }
Exemplo n.º 4
0
 public function testEvitaContagemPorAtributosDuplicada()
 {
     $countableAttributes = ['categoria', 'fornecedor', 'tamanho', 'categoria', 'fornecedor', 'categoria'];
     $keywords = new Keywords();
     $keywords->addKeyword('shampoo');
     $query = new Query();
     $query->setKeyword($keywords);
     $query->setCountableAttributes($countableAttributes);
     $this->assertEquals(3, count($query->getCountableAttributes()));
     $firstQuery = current($query->getQueries());
     $this->assertArrayHasKey('countableAttributes', $firstQuery);
     $this->assertEquals(3, count($firstQuery['countableAttributes']));
 }