/**
  *  issue: when the neighborhood /Region/Neighborhood is pulled for neighborhoods that
  *  have user polygons drawn but no neighborhood borders drawn, they fail
  */
 public function testNeighborhoodsWithNoBorders()
 {
     $this->initDb();
     $region = new \Whathood\Entity\Region(array('name' => 'TestRegion' . rand(0, 99999999)));
     $this->m()->regionMapper()->save($region);
     $whathoodUser = new \Whathood\Entity\WhathoodUser(array('ipAddress' => '0.0.0.0'));
     $neighborhood = new Neighborhood(array('id' => 1, 'name' => "MyTest" . $this->getTestName(), 'region' => $region));
     $userPolygon = new UserPolygon(array('polygon' => Polygon::build(array(new LineString(array(new Point(30, 40), new Point(30, 50), new Point(40, 50), new Point(30, 40)))), 4326), 'neighborhood' => $neighborhood, 'region' => $region, 'whathoodUser' => $whathoodUser));
     $this->m()->userPolygonMapper()->save($userPolygon);
     $this->dispatch(sprintf("/%s/%s", $region->getName(), $neighborhood->getName()));
     $this->assertResponseStatusCode(200);
     $this->assertControllerName('whathood\\controller\\neighborhood');
 }
 public function testSaveUserPolygon()
 {
     $this->initDb();
     $serviceLocator = $this->getServiceLocator();
     $whathoodConfig = $serviceLocator->get('Whathood\\Config');
     $factory = new \Whathood\Factory\NeighborhoodBorderBuilderJobFactory();
     $job = $factory->createService(\WhathoodTest\Bootstrap::getServiceManager());
     $region = new \Whathood\Entity\Region(array('name' => 'Test Region'));
     $whathoodUser = new \Whathood\Entity\WhathoodUser(array('ipAddress' => '0.0.0.0'));
     $neighborhood = new Neighborhood(array('id' => 1, 'name' => "MyTest" . $this->getTestName(), 'region' => $region));
     $userPolygon = new UserPolygon(array('polygon' => Polygon::build(array(new LineString(array(new Point(30, 40), new Point(30, 50), new Point(40, 50), new Point(30, 40)))), 4326), 'neighborhood' => $neighborhood, 'region' => $region, 'whathoodUser' => $whathoodUser));
     $this->m()->userPolygonMapper()->save($userPolygon);
     $this->assertFalse(empty($userPolygon->GetId()));
     $this->assertFalse(empty($userPolygon->getNeighborhood()));
     $this->assertFalse(empty($userPolygon->getNeighborhood()->getId()));
 }
 public function testValidData()
 {
     $this->initDb();
     /**
      * set up test data
      **/
     $region = new \Whathood\Entity\Region(array('name' => "Region_" . $this->getTestName()));
     $whathoodUser = new \Whathood\Entity\WhathoodUser(array('ipAddress' => '0.0.0.0'));
     $neighborhood = new Neighborhood(array('id' => 1, 'name' => "MyTest" . $this->getTestName(), 'region' => $region));
     $userPolygon = new UserPolygon(array('polygon' => Polygon::build(array(new LineString(array(new Point(30, 40), new Point(30, 50), new Point(40, 50), new Point(30, 40)))), 4326), 'neighborhood' => $neighborhood, 'region' => $region, 'whathoodUser' => $whathoodUser));
     $this->m()->userPolygonMapper()->save($userPolygon);
     /*
      * now run the job
      *
      **/
     $factory = new \Whathood\Factory\HeatmapBuilderJobFactory();
     $job = $factory->createService(\WhathoodTest\Bootstrap::getServiceManager());
     $job->setGridResolution(1);
     if (count($neighborhood->getUserPolygons())) {
         die("should have had more than 0 user polygons");
     }
     $job->setContent(array('neighborhood_id' => $userPolygon->getNeighborhood()->getId()));
     $job->execute();
 }
Exemple #4
0
 public static function buildTestPolygon($low = 0, $high = 100, $srid = 4326)
 {
     $start = new Point(rand($low, $high), rand($low, $high));
     return Polygon::build(array(new LineString(array($start, new Point(rand($low, $high), rand($low, $high)), new Point(rand($low, $high), rand($low, $high)), new Point(rand($low, $high), rand($low, $high)), $start))), $srid);
 }