public function testValidData()
 {
     $this->initDb();
     $serviceLocator = $this->getServiceLocator();
     $whathoodConfig = $serviceLocator->get('Whathood\\Config');
     $factory = new \Whathood\Factory\NeighborhoodBorderBuilderJobFactory();
     $job = $factory->createService(\WhathoodTest\Bootstrap::getServiceManager());
     $job->setGridResolution(1);
     $neighborhood = $this->buildTestNeighborhood();
     $region = $neighborhood->getRegion();
     $this->m()->regionMapper()->save($region);
     $whathoodUser = new \Whathood\Entity\WhathoodUser(array('ipAddress' => '0.0.0.0'));
     $userPolygon = $this->buildUserPolygon(array('neighborhood' => $neighborhood, 'region' => $region, 'whathoodUser' => $whathoodUser));
     $this->m()->userPolygonMapper()->save($userPolygon);
     $ups = $this->m()->userPolygonMapper()->fetchAll();
     $neighborhood = $userPolygon->getNeighborhood();
     if (count($neighborhood->getUserPolygons())) {
         die("should have had more than 0 user polygons");
     }
     $job->setContent(array('neighborhood_id' => $neighborhood->getId()));
     try {
         $job->execute();
     } catch (\Exception $e) {
         $this->fail("border job should not have thrown an exception: {$e}");
     }
 }
 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()));
 }