/**
  * Test ipv4 range aggregation with mask range.
  */
 public function testIpv4RangeAggregationWithMask()
 {
     $repo = $this->getManager()->getRepository('AcmeTestBundle:Product');
     $aggregation = new Ipv4RangeAggregation('ip_ranges');
     $aggregation->setField('ip');
     $aggregation->addMask('10.0.0.0/25');
     $search = $repo->createSearch()->addAggregation($aggregation);
     $expectedResult = ['agg_ip_ranges' => ['buckets' => [['key' => '10.0.0.0/25', 'from' => 167772160, 'from_as_string' => '10.0.0.0', 'to' => 167772288, 'to_as_string' => '10.0.0.128', 'doc_count' => 3]]]];
     $results = $repo->execute($search, Repository::RESULTS_RAW);
     $this->assertEquals($expectedResult, $results['aggregations']);
 }
 /**
  * Test exception when field and range are not set.
  *
  * @expectedException \LogicException
  */
 public function testIfExceptionIsThrownWhenFieldAndRangeAreNotSet()
 {
     $agg = new Ipv4RangeAggregation('foo');
     $agg->toArray();
 }