コード例 #1
0
 /**
  * Test Span or query with different span queries.
  */
 public function testSpanOrQuery()
 {
     $repo = $this->getManager()->getRepository('AcmeTestBundle:Product');
     $spanNear = new SpanNearQuery(['in_order' => true]);
     $spanNear->setSlop(1);
     $spanNear->addQuery(new SpanTermQuery('description', 'ipsum'))->addQuery(new SpanTermQuery('description', 'sit'));
     $spanOr = new SpanOrQuery();
     $spanOr->addQuery(new SpanFirstQuery(new SpanTermQuery('description', 'ipsum'), 2))->addQuery($spanNear);
     $search = $repo->createSearch()->addQuery($spanOr);
     $results = $repo->execute($search, Repository::RESULTS_ARRAY);
     $this->assertEquals(2, count($results));
 }
コード例 #2
0
 /**
  * Tests toArray method.
  */
 public function testSpanOrQueryToArray()
 {
     /** @var SpanQueryInterface $mock */
     $mock = $this->mock;
     $query = new SpanOrQuery();
     $query->addQuery($mock);
     $result = ['clauses' => [0 => ['span_or' => ['key' => 'value']]]];
     $this->assertEquals($result, $query->toArray());
     $result = $query->getQueries();
     $this->assertInternalType('array', $result);
     $this->assertEquals(1, count($result));
 }