예제 #1
0
 public static function init($uri, $method, array $params = array(), array $options = array())
 {
     self::reset();
     $uri = parse_url($uri);
     $method = strtoupper($method);
     $_SERVER['REQUEST_URI'] = $uri;
     $_SERVER['REQUEST_METHOD'] = $method;
     if (isset($uri['query'])) {
         $_SERVER['QUERY_STRING'] = $uri['query'];
         parse_str($uri['query'], $_GET);
     }
     if ($method != 'GET') {
         $_POST = $params;
     }
     if (isset($options['ajax']) && $options['ajax']) {
         self::useAjax();
     }
     if (isset($options['header'])) {
         foreach ($options['header'] as $key => $val) {
             self::setHeader($key, $val);
         }
     }
     $_COOKIE = \Test\Mock\Cookie::instance()->get($uri['path']);
     $_REQUEST = array_merge($_GET, $_POST, $_COOKIE);
 }
예제 #2
0
파일: Sandbox.php 프로젝트: lryl/Lysine2
 protected function __construct()
 {
     $this->cookie = \Test\Mock\Cookie::getInstance();
     $this->_server = $_SERVER;
 }
예제 #3
0
파일: Response.php 프로젝트: lryl/Lysine2
 public function setCookie($name, $value, $expire = 0, $path = '/', $domain = null, $secure = false, $httponly = true)
 {
     \Test\Mock\Cookie::instance()->set($name, $value, $expire, $path, $domain, $secure, $httponly);
 }
예제 #4
0
 public function testBindIpCookieContext()
 {
     $mock_cookie = \Test\Mock\Cookie::getInstance();
     $mock_cookie->reset();
     $config = array('token' => 'test', 'sign_salt' => 'fdajkfldsjfldsf', 'bind_ip' => true);
     $_SERVER['REMOTE_ADDR'] = '192.168.1.1';
     $handler = new \Lysine\CookieContextHandler($config);
     $handler->set('test', 'abc');
     $mock_cookie->apply();
     $handler->reset();
     $_SERVER['REMOTE_ADDR'] = '192.168.1.3';
     $this->assertEquals($handler->get('test'), 'abc', '同子网IP取值');
     $handler->reset();
     $_SERVER['REMOTE_ADDR'] = '192.168.2.1';
     $this->assertNull($handler->get('test'), '不同子网IP取值');
 }