Example #1
0
 protected function _before()
 {
     $this->get = array('getParam1' => 'getParam1Value');
     $this->post = array('postParam1' => 'postParam1Value');
     $this->cookie = array('cookieParam1' => 'cookieParam1Value');
     $this->server = array('REQUEST_URI' => '/test', 'REQUEST_METHOD' => 'POST');
     $this->routes = array('/' => array('controller' => 'index', 'action' => 'index', 'params' => array()), '/test' => array('controller' => 'index', 'action' => 'test', 'params' => array('drink' => 'grog', 'speak' => 'pirate')), '/custom/:mandatory/[:optional]' => array('controller' => 'index', 'action' => 'test', 'params' => array('drink' => 'grog', 'speak' => 'pirate')));
     $this->registry = Registry::ahoy();
     $this->registry->set('routes', $this->routes);
     $this->request = new Request($this->get, $this->post, $this->cookie, $this->server);
 }
Example #2
0
 /**
  *  Tells the Navigator to go to the / route
  */
 private function sailHome()
 {
     $routes = Registry::ahoy()->get('routes');
     $home_page = $routes['/'];
     $this->controller = $home_page['controller'];
     $this->action = $home_page['action'];
     $this->params = $home_page['params'];
 }
 public function testFireCannons()
 {
     $loader = new Twig_Loader_String();
     $twig = new Twig_Environment($loader);
     Registry::ahoy()->set('templates', 'blah');
     Test::double('Bone\\Mvc\\Dispatcher', ['checkNavigator' => null, 'sinkingShip' => 'glurg']);
     $headers = new Headers();
     $dispatcher = new Dispatcher($this->request, $this->response);
     $controller = new Controller($this->request);
     $this->setPrivateProperty($controller, 'headers', $headers);
     $this->setPrivateProperty($controller, '_twig', $twig);
     $this->setPrivateProperty($dispatcher, 'controller', $controller);
     $config = ['controller_name' => 'Bone\\Mvc\\Controller', 'action_name' => 'init', 'controller' => 'controller', 'action' => 'init'];
     $this->setPrivateProperty($dispatcher, 'config', $config);
     $this->assertNull($dispatcher->fireCannons());
     $dispatcher = new Dispatcher($this->request, $this->response);
     $controller = new Controller($this->request);
     $this->setPrivateProperty($dispatcher, 'controller', $controller);
     $this->setPrivateProperty($dispatcher, 'config', $config);
     $dispatcher->fireCannons();
 }
Example #4
0
 /**
  *  @param Controller $controller
  *  @param string $content
  *  @return string
  */
 private function templateCheck($controller, $content, array $view_vars = [])
 {
     $response_body = '';
     //check we be usin' th' templates in th' config
     $templates = Registry::ahoy()->get('templates');
     $template = $templates != null ? $templates[0] : null;
     if ($template) {
         $view_vars['content'] = $content;
         $response_body = $controller->getTwig()->render('layouts/' . $template . '.twig', $view_vars);
     }
     return $response_body;
 }
Example #5
0
 /**
  * @return null
  */
 protected function setDB()
 {
     $config = Registry::ahoy()->get('db');
     $this->_db = new MySQL($config);
 }