Ejemplo n.º 1
0
 public function setUp()
 {
     DI::reset();
     DI::setDefault($di = new DI());
     $this->instance = m::mock('Phalcore\\Di\\Facade');
     $di->setShared('foo', m::mock('foo'));
 }
Ejemplo n.º 2
0
Archivo: Tpl.php Proyecto: arhcmf/1
 /**
  * @param DI $DI
  */
 function __construct(DI $DI)
 {
     $this->Modules = $DI->get('\\arh\\library\\Modules');
     $this->Settings = $DI->get('\\arh\\library\\Settings');
     $this->Access = $DI->get('\\arh\\library\\Access');
     $this->Exception = $DI->get('\\arh\\library\\Exception');
 }
Ejemplo n.º 3
0
 /**
  * @expectedException           \Phalcon\Mvc\Model\Exception
  * @expectedExceptionMessage    Field name must be a string
  */
 public function testValidateIncorrectFieldType()
 {
     $di = new DI();
     $di->set('modelsManager', new Manager());
     require_once __DIR__ . '/resources/TestCardNumberIncorrectField.php';
     $obj = new \TestCardNumberIncorrectField();
     $obj->validation();
 }
 public function setUp()
 {
     DI::reset();
     $this->instance = new ExceptionHandler();
     $this->instance->setDI($di = new DI());
     $di->setShared('config', m::mock('Phalcon\\Config'));
     $this->instance->register();
 }
Ejemplo n.º 5
0
 public function setUp()
 {
     DI::reset();
     $this->instance = new Module();
     $this->instance->setDI($di = new DI());
     $di->setShared('application', m::mock('Phalcore\\Mvc\\Application')->makePartial());
     $this->instance->register();
 }
 public function setUp()
 {
     DI::reset();
     $this->instance = new LoadEnvironmentVariables();
     $this->instance->setDI($di = new DI());
     $this->application = m::mock('Phalcore\\Mvc\\Application')->makePartial();
     $di->setShared('application', $this->application);
 }
Ejemplo n.º 7
0
 public function setUp()
 {
     DI::reset();
     $this->instance = new RegisterConfig();
     $this->instance->setDI($di = new DI());
     $this->application = m::mock('Phalcore\\Mvc\\Application')->makePartial();
     $di->setShared('application', $this->application);
     $this->instance->boot();
 }
Ejemplo n.º 8
0
 /**
  * @param DI $DI
  */
 function __construct(DI $DI)
 {
     $this->ROOT_DIR = $DI->get('ROOT_DIR');
     $this->Exception = $DI->get('\\library\\Exception');
     $this->configDir = $this->ROOT_DIR . '/' . $this->configDir;
     $this->modulesDir = $this->ROOT_DIR . '/' . $this->modulesDir;
     self::$modules = $this->getAll();
     self::$current = $this->getInfo('arh');
 }
Ejemplo n.º 9
0
 public function setUp()
 {
     DI::reset();
     $this->instance = new Router();
     $this->instance->setDI($di = new DI());
     $config = m::mock('Phalcore\\Config');
     $config->files = m::mock('Phalcon\\Config');
     $config->files->routes = APP_PATH . '/config/routes.php';
     $di->setShared('config', $config);
     $this->instance->register();
 }
Ejemplo n.º 10
0
 public function setUp()
 {
     DI::reset();
     $this->instance = new Dispatcher();
     $this->instance->setDI($di = new DI());
     $config = m::mock('Phalcon\\Config')->makePartial();
     $config->offsetSet('namespaces', ['controllers' => 'barFoo']);
     $di->setShared('config', $config);
     $di->setShared('router', m::mock('Phalcore\\Mvc\\Router')->makePartial());
     $this->instance->register();
 }
Ejemplo n.º 11
0
 public function setUp()
 {
     DI::reset();
     $this->instance = new Logger();
     $this->instance->setDI($di = new DI());
     $config = m::mock('Phalcon\\Config');
     $config->files = m::mock('Phalcon\\Config');
     $config->files->logs = m::mock('Phalcon\\Config');
     $config->files->logs->error = APP_PATH . '/trash/foo';
     $di->setShared('config', $config);
     $this->instance->register();
 }
Ejemplo n.º 12
0
 public function setUp()
 {
     DI::reset();
     $this->instance = new View();
     $this->instance->setDI($di = new DI());
     $config = m::mock('Phalcon\\Config');
     $config->paths = m::mock('Phalcon\\Config');
     $config->debug = true;
     $config->paths->cache = 'foo/cache';
     $config->paths->views = 'foo/views';
     $this->config = $config;
     $di->setShared('config', $config);
     $this->instance->register();
 }
Ejemplo n.º 13
0
 protected function _before()
 {
     if (!extension_loaded('MongoDB')) {
         $this->markTestSkipped("MongoDB extension not loaded, test skipped");
         return;
     }
     Di::reset();
     $di = new DI();
     $di->set('mongo', function () {
         $mongo = new MongoClient('mongodb://' . TEST_MONGODB_HOST . ':' . TEST_MONGODB_PORT);
         return $mongo->selectDatabase('phalcon_test');
     });
     $di->set('collectionManager', function () {
         return new Manager();
     });
 }
Ejemplo n.º 14
0
 public function setUp()
 {
     $config = (include __DIR__ . '/../config.php');
     $this->config = $config;
     $this->di = DI::getDefault();
     $this->loadAnnotations();
 }
Ejemplo n.º 15
0
 public function setUp()
 {
     DI::reset();
     $this->instance = new Db();
     $this->instance->setDI($di = new DI());
     $this->instance->register();
 }
Ejemplo n.º 16
0
 public function __construct($file)
 {
     $config = DI::get('config');
     $logDir = $config->dir->log;
     $this->file = $logDir . $file;
     $this->fp = fopen($this->file, 'a+');
 }
Ejemplo n.º 17
0
 /**
  * Set the host and port of the endpoint
  *
  * @param string $host
  * @param integer $port
  */
 public function __construct($host = 'localhost', $port = 7474)
 {
     $this->host = $host;
     $this->port = $port;
     if (DI::isRegistered("dbPath")) {
         $this->path = DI::resolve("dbPath");
     }
 }
Ejemplo n.º 18
0
Archivo: DI.php Proyecto: jankal/mvc
 /**
  * add an object as singleton
  * @param object $obj
  * @return void
  */
 public static function addInstance($obj)
 {
     if (null === self::$instances) {
         self::$instances = (object) array();
     }
     $key = get_class($obj);
     self::$instances->{$key} = $obj;
 }
Ejemplo n.º 19
0
 /**
  * start all registered classes
  * @return void
  */
 public static function go()
 {
     foreach (self::$startup as $classname) {
         $classname::startup();
     }
     foreach (self::$DIstartup as $classname) {
         \DI::getInstanceOf($classname)->startup();
     }
 }
Ejemplo n.º 20
0
Archivo: Raw.php Proyecto: jankal/mvc
 /**
  * @return void
  */
 public static function go()
 {
     self::$used = true;
     $msqlo = new MySQLi(app::get('mysql')->host, app::get('mysql')->user, app::get('mysql')->password, app::get('mysql')->database);
     \DI::addInstance($msqlo);
     $modelob = new \Observer\ModelObserver();
     \DI::addInstance($modelob);
     \StartupAll::startup();
 }
Ejemplo n.º 21
0
 /**
  * Set up the test environment
  * @return void
  */
 public function setUp()
 {
     //$this->controller = new LoginController;
     $this->controller = new LoginController();
     $this->view = new View();
     $this->view->disable();
     $this->di = DI::getDefault();
     parent::setUp();
 }
Ejemplo n.º 22
0
 /**
  * {@inheritdoc}
  */
 public function handle(\Request $request)
 {
     $responseObject = new \Response();
     self::$response = $responseObject;
     self::$request = $request;
     \DI::addInstance($responseObject);
     \Route::map();
     $connection = new \Connection(self::$request, self::$response);
     return $connection->close();
 }
Ejemplo n.º 23
0
 public function __get($var_name)
 {
     $di = DI::getDefault();
     if ($di->hasService($var_name)) {
         return $di->getService($var_name);
     }
     if ($var_name == "di") {
         return $di;
     }
 }
Ejemplo n.º 24
0
 /**
  * Redirects to another page.
  *
  * @param string $location The path to redirect to
  * @param int $status Status code to use
  * @return bool False if $location is not set
  */
 public static function redirect($location, $status = 302)
 {
     $request = DI::get('request');
     if ($location == '') {
         header("Location: " . $request->get_uri('site_url'), true, $status);
         exit;
     }
     header("Location: " . $request->get_uri('site_url') . $location, true, $status);
     exit;
 }
Ejemplo n.º 25
0
 /**
  * Set up the test environment
  * @return void
  */
 public function setUp()
 {
     //need to use mock feature to remove contructor and exit functions
     $this->controller = new MockApiController();
     //setup our view if needed
     $this->view = new View();
     $this->di = DI::getDefault();
     //call parent setup if any
     parent::setUp();
 }
Ejemplo n.º 26
0
 /**
  * Check if \Phalcon\Di has session service
  *
  * @return bool
  */
 private function hasSession()
 {
     if (DI::getDefault()->has('session') === true) {
         // get instance of session class
         $this->session = DI::getDefault()->getSession();
         if ($this->session->getId() === '') {
             $this->session->start();
         }
         return true;
     }
     return false;
 }
 /**
  * get a service from the di
  * @param $what
  * @return mixed the service object
  */
 public function get($what)
 {
     if (!$this->registered($what)) {
         $file = $this->directory . "/{$what}.php";
         $service = (include $file);
         if (!is_callable($service)) {
             throw new Exception(sprintf('Bad service type. The file%s should return a callable', $file));
         }
         $this->set($what, $service);
     }
     return parent::get($what);
 }
Ejemplo n.º 28
0
Archivo: Tpl.php Proyecto: arhcms/1.2
 /**
  * @param DI $DI
  */
 function __construct(DI $DI)
 {
     $this->ROOT_DIR = $DI->get('ROOT_DIR');
     $this->Modules = $DI->get('\\library\\Modules');
     $this->Config = $DI->get('\\library\\Config');
     $this->Access = $DI->get('\\library\\Access');
     $this->Exception = $DI->get('\\library\\Exception');
 }
Ejemplo n.º 29
0
Archivo: Auth.php Proyecto: jankal/mvc
 /**
  * {@inheritDoc}
  *
  * @todo if logged in
  * @todo set user in config!!!
  */
 public function run(array $args, $required = true)
 {
     $user = new \Authentication\User($args['session'], \DI::prepare("\\Model\\" . \app::get("user")));
     $loggedIn = $user->isAuthenticated();
     // if loggedin
     if ($loggedIn) {
         $this->assignTplVar("loggedIn", true);
         $this->assignTplVar("user", $user);
         return true;
     } elseif (!$loggedIn && $required) {
         $this->error("Not authorized to access this page!");
         return false;
     } else {
         $this->assignTplVar("loggedIn", false);
         return true;
     }
     return false;
 }
Ejemplo n.º 30
0
 /**
  * @param  string $path
  * @return void
  */
 public function go($path)
 {
     $this->cache = \DI::getInstanceOf('Cache', ['css']);
     if ('css' == self::$prefered) {
         $out = $this->css($path);
         if (!$out) {
             $out = $this->less($path);
         }
     } else {
         $out = $this->less($path);
         if (!$out) {
             $out = $this->css($path);
         }
     }
     if (!$out) {
         $this->response->errorCode(404)->out(sprintf("<h1>%s!</h1>", __('File not found')));
     }
 }