Example #1
0
 public function setUp()
 {
     $basePath = __DIR__ . '/../../../../../';
     $this->setApplicationConfig(include $basePath . 'config/application.config.php');
     $serviceManager = Bootstrap::getServiceManager();
     $this->controller = new \Galaxy\Controller\IndexController();
     $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);
     $mockAuth = $this->getMock('ZfcUser\\Entity\\UserInterface');
     $ZfcUserMock = $this->getMock('User\\Entity\\User');
     $ZfcUserMock->expects($this->any())->method('getId')->will($this->returnValue('3'));
     $authMock = $this->getMock('ZfcUser\\Controller\\Plugin\\ZfcUserAuthentication');
     $authMock->expects($this->any())->method('hasIdentity')->will($this->returnValue(true));
     $authMock->expects($this->any())->method('getIdentity')->will($this->returnValue($ZfcUserMock));
     $this->controller->getPluginManager()->setService('zfcUserAuthentication', $authMock);
     parent::setUp();
 }
 public function setUp()
 {
     $this->initDatabaseAdapter();
     $this->sm = Bootstrap::getServiceManager();
     $this->sm->setAllowOverride(true);
     $this->sm->setService('Galaxy\\Entity\\SystemObject', new \Galaxy\Entity\SystemObject());
     $this->sm->setService('Zend\\Db\\Adapter\\Adapter', $this->dbAdapter);
 }
Example #3
0
 public function setUp()
 {
     $this->sm = Bootstrap::getServiceManager();
     $this->sm->setAllowOverride(true);
     $servicesToMock = array('Zend\\Db\\Adapter\\Adapter' => 'Zend\\Db\\Adapter\\Adapter', 'Core\\Service\\Tick' => 'Core\\Service\\Tick', 'logger' => 'Zend\\Log\\Logger', 'Galaxy\\Table\\SystemTable' => 'Galaxy\\Table\\SystemTable', 'Galaxy\\Table\\SystemObjectTable' => 'Galaxy\\Table\\SystemObjectTable', 'Colony\\Table\\ColonyTable' => 'Colony\\Table\\ColonyTable', 'Fleet\\Table\\FleetTable' => 'Fleet\\Table\\FleetTable', 'Fleet\\Table\\FleetShipTable' => 'Fleet\\Table\\FleetShipTable', 'Fleet\\Table\\FleetPersonellTable' => 'Fleet\\Table\\FleetPersonellTable', 'Fleet\\Table\\FleetResearchTable' => 'Fleet\\Table\\FleetResearchTable', 'Fleet\\Table\\FleetOrderTable' => 'Fleet\\Table\\FleetOrderTable', 'Fleet\\Table\\FleetResourceTable' => 'Fleet\\Table\\FleetResourceTable', 'Techtree\\Table\\ColonyBuildingTable' => 'Techtree\\Table\\ColonyBuildingTable', 'Resources\\Table\\ColonyTable' => 'Resources\\Table\\ColonyTable');
     foreach ($servicesToMock as $key => $serviceName) {
         $this->sm->setService($key, $this->getMockBuilder($serviceName)->disableOriginalConstructor()->getMock());
     }
 }
Example #4
0
            } elseif (is_dir($vendorPath . '/ZF2/library')) {
                $zf2Path = $vendorPath . '/ZF2/library';
            } elseif (is_dir($vendorPath . '/zendframework/zendframework/library')) {
                $zf2Path = $vendorPath . '/zendframework/zendframework/library';
            }
        }
        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__))));
    }
    /**
     * @param string $path
     */
    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();