예제 #1
0
파일: view.php 프로젝트: ahmed555/Cupcake
 public function render()
 {
     $layout = $this->content_for_template();
     $body = $this->content_for_layout($layout);
     // Needed for testing
     if (CUPCAKE_ENV === "test") {
         $dispatcher = DispatcherTest::getInstance();
         $dispatcher->__params = $this->view_params();
         $dispatcher->__view_params = $this->view_params;
         $dispatcher->__template = $this->template;
         $dispatcher->__layout = $this->layout;
         # Action might be false positive and controller aswell.
         $dispatcher->__controller = $this->controller;
         $dispatcher->__action = $this->params["action"];
         $dispatcher->__request_uri = $this->request_uri;
         $dispatcher->__body = $body;
         return;
     }
     if (!empty($this->content_type)) {
         Header::set("Content-Type", $this->content_type);
         Header::send();
     }
     echo $body;
     exit;
 }
예제 #2
0
    {
    }
    /**
     * Tears down the fixture, for example, close a network connection.
     * This method is called after a test is executed.
     *
     * @access protected
     */
    protected function tearDown()
    {
    }
    /**
     * @todo Implement testDispatch().
     */
    public function testDispatch()
    {
        // Remove the following line when you implement this test.
        throw new PHPUnit2_Framework_IncompleteTestError();
    }
}
// Call DispatcherTest::main() if this source file is executed directly.
if (PHPUnit2_MAIN_METHOD == "DispatcherTest::main") {
    DispatcherTest::main();
}
// -- set Emacs parameters --
// Local variables:
// tab-width: 4
// c-basic-offset: 4
// c-hanging-comment-ender-p: nil
// indent-tabs-mode: nil
// End:
예제 #3
0
 public function make_request($request_uri)
 {
     $_SERVER['REQUEST_URI'] = $request_uri;
     $this->dispatcher = DispatcherTest::getInstance();
     DispatcherTest::run();
 }
예제 #4
0
 public static function setUpBeforeClass()
 {
     $router = new \Buuum\Router();
     $router->filter('notauth', function () {
         return 'not auth';
     });
     $router->filter('auth', function () {
         // CHECK AUTH //
     });
     $router->filter('params', function ($id, $_requesturi) {
         // CHECK AUTH //
         return "filter params {$id} {$_requesturi['scheme']}";
     });
     $router->get('/', function () {
         return "controller index";
     })->setName('index');
     $router->any('/any/', function () {
         return "controller any";
     })->setName('any');
     $router->map(['GET', 'POST'], '/map/', function () {
         return "controller map";
     });
     $router->get(['/group/', '/en/group/', '/fr/group/'], function () {
         return "controller group";
     });
     $router->put('/put/', function () {
         return "controller put";
     });
     $router->post('/', function () {
         return 'controller index post';
     });
     $router->get('/items/', function () {
         return 'controller items';
     })->setName('items');
     $router->get('/itemsr/', function ($_requesturi) {
         return "controller itemsr {$_requesturi['scheme']} {$_requesturi['host']}";
     });
     $router->group(['prefix' => 'prefixitem'], function (\Buuum\Router $router) {
         $router->get('/itemsr2/', function ($_requesturi, $_prefix) {
             return "controller itemsr2 {$_requesturi['scheme']} {$_requesturi['host']} {$_prefix}";
         });
     });
     $router->get('/itemsr/', function ($_requesturi) {
         return "controller itemsr {$_requesturi['scheme']} {$_requesturi['host']}";
     })->setHost('routes2.dev');
     $router->get('/items2', function () {
         return 'controller items';
     })->setName('items2');
     $router->get('/itemsview', function () {
         return 'controller itemsview';
     });
     $router->get('/item/{id:[0-9]+}', function ($id) {
         return 'controller item ' . $id;
     });
     $router->get('/viewitem/{id:[0-9]+}/', function ($id) {
         return 'view item ' . $id;
     })->setName('viewitem')->setScheme('https');
     $router->group(['before' => ['params']], function (\Buuum\Router $router) {
         $router->get('/filterparams/{id:[0-9]+}/', function ($id) {
             return "controller filter params {$id}";
         });
     });
     $router->group(['before' => ['auth']], function (\Buuum\Router $router) {
         $router->get('/before/', function () {
             return 'controller index with before filter';
         });
     });
     $router->group(['before' => ['notauth']], function (\Buuum\Router $router) {
         $router->get('/before/not/', function () {
             return 'controller index with before filter';
         });
     });
     $router->group(['after' => ['auth']], function (\Buuum\Router $router) {
         $router->get('/after/', function () {
             return 'controller index with after filter';
         });
     });
     $router->group(['after' => ['notauth']], function (\Buuum\Router $router) {
         $router->get('/after/not/', function () {
             return 'controller index with after filter';
         });
     });
     $router->group(['prefix' => 'name-prefix'], function (\Buuum\Router $router) {
         $router->get('/', function () {
             return 'controller prefix name-prefix';
         });
         $router->get('/', function () {
             return 'controller https prefix name-prefix';
         })->setScheme('https');
         $router->get('/', function () {
             return 'controller routes2 prefix name-prefix';
         })->setHost('routes2.dev');
         $router->get('/route1', function () {
             return 'controller prefix name-prefix route1';
         });
         $router->group(['prefix' => 'sub-prefix'], function (\Buuum\Router $router) {
             $router->get('/', function () {
                 return 'controller prefix name-prefix/sub-prefix';
             });
             $router->get('/route1/', function () {
                 return 'controller prefix name-prefix/sub-prefix route1';
             });
         });
     });
     $router->group(['prefix' => 'en'], function (\Buuum\Router $router) {
         $router->get('/', function () {
             return 'home with prefix en';
         })->setName('home');
     });
     $router->group(['prefix' => 'es'], function (\Buuum\Router $router) {
         $router->get('/', function () {
             return 'home with prefix es';
         })->setName('home');
     });
     $router->get('/home/', function () {
         return 'home without prefix';
     })->setName('home');
     $router->get('/home/{id:[0-9]+}/', function ($id, $_requesturi, $_prefix) {
         return "home without prefix {$id} {$_requesturi['scheme']} {$_requesturi['host']} {$_prefix}";
     })->setScheme('https');
     self::$router = $router;
 }