toArray() public method

public toArray ( ) : array
return array
 public function testToArray()
 {
     $expected = array("filter" => array("range" => array("stock" => array("gt" => 0))), "aggs" => array("avg_price" => array("avg" => array("field" => "price"))));
     $agg = new Filter("in_stock_products");
     $agg->setFilter(new Range("stock", array("gt" => 0)));
     $avg = new Avg("avg_price");
     $avg->setField("price");
     $agg->addAggregation($avg);
     $this->assertEquals($expected, $agg->toArray());
 }
 /**
  * @group unit
  */
 public function testConstructWithLegacyFilter()
 {
     $this->hideDeprecated();
     $agg = new Filter('foo', new Term(array('color' => 'blue')));
     $this->showDeprecated();
     $expected = array('filter' => array('term' => array('color' => 'blue')));
     $this->assertEquals($expected, $agg->toArray());
 }
Example #3
0
 /**
  * @group unit
  */
 public function testConstruct()
 {
     $agg = new Filter('foo', new Term(array('color' => 'blue')));
     $expected = array('filter' => array('term' => array('color' => 'blue')));
     $this->assertEquals($expected, $agg->toArray());
 }