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 setUp()
 {
     parent::setUp();
     if (getenv('APPLICATION_ENV') !== 'test') {
         throw new \Exception("you must set APPLICATION_ENV to 'test'");
     }
     $this->sm = Bootstrap::getServiceManager();
     $this->setApplicationConfig(include 'TestConfig.php');
     $this->setRemoteAddr();
     $this->initTestName();
     $this->setDbName();
 }
 public function setUp()
 {
     $serviceManager = Bootstrap::getServiceManager();
     $this->controller = new RegionRestController();
     $this->request = new Request();
     $this->routeMatch = new RouteMatch(array('controller' => 'index'));
     $this->event = new MvcEvent();
     $config = $serviceManager->get('Config');
     $routerConfig = isset($config['router']) ? $config['router'] : array();
     $router = HttpRouter::factory($routerConfig);
     $this->event->setRouter($router);
     $this->event->setRouteMatch($this->routeMatch);
     $this->controller->setEvent($this->event);
     $this->controller->setServiceLocator($serviceManager);
 }
示例#4
0
 public function setUp()
 {
     parent::setUp();
     if (getenv('APPLICATION_ENV') !== 'test') {
         throw new \Exception("you must set APPLICATION_ENV to 'test'");
     }
     $this->sm = Bootstrap::getServiceManager();
     $this->setApplicationConfig(include 'TestConfig.php');
     try {
         $this->sm->get('doctrine.entitymanager.orm_default');
     } catch (\Exception $e) {
         $this->create_database("whathood_test");
         $this->initDb();
     }
 }
 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();
 }
示例#7
0
 public function getServiceManager()
 {
     return \WhathoodTest\Bootstrap::getServiceManager();
 }
示例#8
0
    }
    protected static function initAutoloader()
    {
        $vendorPath = static::findParentPath('vendor');
        if (is_readable($vendorPath . '/autoload.php')) {
            $loader = (include $vendorPath . '/autoload.php');
        } else {
            $zf2Path = getenv('ZF2_PATH') ?: (defined('ZF2_PATH') ? ZF2_PATH : (is_dir($vendorPath . '/ZF2/library') ? $vendorPath . '/ZF2/library' : false));
            if (!$zf2Path) {
                throw new RuntimeException('Unable to load ZF2. Run `php composer.phar install` or define a ZF2_PATH environment variable.');
            }
            include $zf2Path . '/Zend/Loader/AutoloaderFactory.php';
        }
        AutoloaderFactory::factory(array('Zend\\Loader\\StandardAutoloader' => array('autoregister_zf' => true, 'namespaces' => array(__NAMESPACE__ => __DIR__ . '/' . __NAMESPACE__))));
    }
    protected static function findParentPath($path)
    {
        $dir = __DIR__;
        $previousDir = '.';
        while (!is_dir($dir . '/' . $path)) {
            $dir = dirname($dir);
            if ($previousDir === $dir) {
                return false;
            }
            $previousDir = $dir;
        }
        return $dir . '/' . $path;
    }
}
Bootstrap::init();