예제 #1
0
 public function setUp(Phalcon\DiInterface $di = NULL, Phalcon\Config $config = NULL)
 {
     // Load any additional services that might be required during testing
     include __DIR__ . '/../config/services.php';
     include __DIR__ . '/../config/loader.php';
     // $di = DI::getDefault();
     // get any DI components here. If you have a config, be sure to pass it to the parent
     $di->set('dispatcher', function () {
         $dispatcher = new Phalcon\Mvc\Dispatcher();
         $dispatcher->setControllerName($this->_ctrl);
         $dispatcher->setActionName($this->_act);
         return $dispatcher;
     }, true);
     $this->di = $di;
     parent::setUp($di);
     $this->_loaded = true;
 }
예제 #2
0
 public function testIssues2270()
 {
     Phalcon\DI::reset();
     $di = new \Phalcon\DI();
     $dispatcher = new \Phalcon\Mvc\Dispatcher();
     $dispatcher->setDI($di);
     $dispatcher->setDefaultNamespace('A\\B\\C');
     $dispatcher->setControllerName('Test');
     $dispatcher->setActionName('index');
     $this->assertEquals('A\\B\\C\\TestController', $dispatcher->getHandlerClass());
 }
<?php

$di = new Phalcon\DI();
$dispatcher = new Phalcon\Mvc\Dispatcher();
$dispatcher->setDI($di);
$dispatcher->setControllerName('posts');
$dispatcher->setActionName('index');
$dispatcher->setParams(array());
$controller = $dispatcher->dispatch();