Пример #1
0
 /**
  * given an array of test points, build a collection of election test points
  *
  * @param array - an array of test point objects
  * @return mixed - PointElectionCollection
  */
 public function buildPointElectionCollection(array $test_points)
 {
     if (empty($test_points)) {
         throw new \InvalidArgumentException("test_points may not be empty");
     }
     $c_points = array();
     foreach ($test_points as $p) {
         $user_polygons = $this->m()->userPolygonMapper()->byPoint($p);
         array_push($c_points, PointElection::build(array('point' => $p, 'userPolygons' => $user_polygons, 'logger' => $this->logger())));
     }
     return new PointElectionCollection($c_points);
 }
Пример #2
0
 /**
  * will return a random point election
  * @return PointElection
  */
 public static function buildTestPointElection(array $data = null)
 {
     if (empty($data)) {
         $data = array();
     }
     $user_polygons = array(static::buildTestUserPolygon(), static::buildTestUserPolygon(), static::buildTestUserPolygon());
     $x = static::rand_int();
     $y = static::rand_int();
     $defaults = array('point' => Point::buildFromText("POINT({$x} {$y})"), 'user_polygons' => $user_polygons, 'logger' => new \Whathood\Logger());
     return PointElection::build(array_merge($defaults, $data));
 }