示例#1
0
文件: CCUrl.php 项目: clancats/core
 /**
  * CCUrl::action
  */
 public function test_action()
 {
     CCRouter::on('test_action', 'CCUnit::Test');
     CCRequest::uri('test_action/detail')->perform();
     $this->assertEquals('/test_action/detail/?woo=yay', CCUrl::action('detail/', array('woo' => 'yay')));
     $this->assertEquals('/test_action/?woo=yay', CCUrl::action('index', array('woo' => 'yay')));
     $this->assertEquals('/test_action/', CCUrl::action());
     // another route
     CCRouter::on('test_action/wurst', 'CCUnit::Test');
     CCRequest::uri('test_action/wurst/detail')->perform();
     $this->assertEquals('/test_action/wurst/detail/?woo=yay', CCUrl::action('detail/', array('woo' => 'yay')));
     $this->assertEquals('/test_action/wurst/?woo=yay', CCUrl::action('index', array('woo' => 'yay')));
     $this->assertEquals('/test_action/wurst/', CCUrl::action());
 }
<?php

/*
 *---------------------------------------------------------------
 * ClanCatsFramework runner
 *---------------------------------------------------------------
 *
 * This file just loads CCF and all needed resources to run the 
 * php unit tests. PHPUnit is a really elegant way to make sure 
 * that everything works how it should.
 *
 *---------------------------------------------------------------
 * Require CCF
 *---------------------------------------------------------------
 *
 * load the framework file wich wil initialize CCF. 
 */
require_once __DIR__ . "/clancatsapp/framework.php";
/*
 * execute the main request
 * The main request contains the params of the http header
 */
$response = CCRequest::uri(CCServer::uri())->perform()->response();
/*
 * "send" means actaully printing the response.
 * If the secound parameter is true the response will 
 * also set headers
 */
$response->send(true);
示例#3
0
 /**
  * error response
  * executes an private route with the error status code and 
  * delivers the resulting response
  *
  * @param int 		$status
  * @return CCResponse
  */
 public static function error($status)
 {
     return CCRequest::uri('#' . $status)->perform()->response();
 }
示例#4
0
 /**
  * Tests the CCRouter filter escaping
  */
 public function test_escaping()
 {
     CCRouter::on('this/u$l/conta([num])n+special/[any]', function () {
         echo "Escaping works";
     });
     $response = CCRequest::uri('this/u$l/conta(1)n+special/chars')->perform()->response()->body;
     $this->assertEquals($response, "Escaping works");
 }