/** * this method is called by the Where I've Been network abstraction layer when a users map has been * updated, it writes a users profile to facebook */ public function test_publish_profile() { $test_user = $this->getUser(); $params = array(); dispatch_controller('user/publish_profile', $params, $test_user); // assert we got the correct URI $this->assertViewURI('json/success'); }
/** * try and save an inhabitant with a missing field * * @expectedException Exception */ public function test_save_inhabitant_missing_file() { $params = array(); dispatch_controller('inhabitant/save_inhabitant', $params); // assert we got the correct URI $this->assertViewURI('json/success'); }
* the HTTP/HTML Template Handler & Presentation Layer (the view in mvc) */ require 'view.php'; // we are serving templates out of this folder Template::setTemplatePath(CORE_PATH . 'view/'); // we are serving templates out of this folder Template::setLayoutPath(SITE_ROOT . 'htdoc/layout/'); // the uri to target the controller $controller = array_val($_REQUEST, 'controller'); // lots of people are going to hate this but i want to enforce denying access to global variables // if we enforce use of $params, it makes is much easier to write tests, and create code which scales $params = $_REQUEST; $_REQUEST = $_GET = $_POST = array(); // the controller to dispatch is determined by the controller $_REQUEST variable // the parameters to pass in are from the http request // and we are using the HTTP/HTML View try { // dispatch_controller($controller, $params, $user); } catch (Exception $e) { // send the error to the error controller with the generated message $controller_obj = c('error'); // a useful message in dev, or a safe message for production if (ENV == 'dev') { $message = $e->getMessage() . ' : ' . $e->getFile() . ' : ' . $e->getLine(); } else { $message = 'There has been an error, please try again'; } // call the error controller $controller_obj->call('error500', array('message' => $message)); }
/** * test the helper function to get sprites */ public function testControllerDispatch() { // this is a very simple controller that always exists, good for a basic test dispatch_controller('error/error404'); $this->assertViewURI('page/error/404'); }