[ Index ]

PHP Cross Reference of DokuWiki

title

Body

[close]

/_test/core/ -> TestRequest.php (summary)

Simulates a full DokuWiki HTTP Request and allows runtime inspection.

File Size: 282 lines (7 kb)
Included or required: 1 time
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

TestRequest:: (16 methods):
  getServer()
  getSession()
  getGet()
  getPost()
  getScript()
  setServer()
  setSession()
  setGet()
  setPost()
  execute()
  setUri()
  post()
  get()
  ob_start_callback()
  getRunning()
  addData()


Class: TestRequest  - X-Ref

Helper class to execute a fake request

getServer($key)   X-Ref
Get a $_SERVER var

return: mixed
param: string $key

getSession($key)   X-Ref
Get a $_SESSION var

return: mixed
param: string $key

getGet($key)   X-Ref
Get a $_GET var

return: mixed
param: string $key

getPost($key)   X-Ref
Get a $_POST var

return: mixed
param: string $key

getScript()   X-Ref
Get the script that will execute the request

return: string

setServer($key, $value)   X-Ref
Set a $_SERVER var

param: string $key
param: mixed $value

setSession($key, $value)   X-Ref
Set a $_SESSION var

param: string $key
param: mixed $value

setGet($key, $value)   X-Ref
Set a $_GET var

param: string $key
param: mixed $value

setPost($key, $value)   X-Ref
Set a $_POST var

param: string $key
param: mixed $value

execute($uri = '/doku.php')   X-Ref
Executes the request

return: TestResponse the resulting output of the request
param: string $uri end URL to simulate, needs to be one of the testable scripts

setUri($uri)   X-Ref
Set the virtual URI the request works against

This parses the given URI and sets any contained GET variables
but will not overwrite any previously set ones (eg. set via setGet()).

It initializes the $_SERVER['REQUEST_URI'] and $_SERVER['QUERY_STRING']
with all set GET variables.

param: string $uri end URL to simulate

post($post = array()   X-Ref
Simulate a POST request with the given variables

return: TestResponse
param: array $post all the POST parameters to use
param: string $uri end URL to simulate

get($get = array()   X-Ref
Simulate a GET request with the given variables

return: TestResponse
param: array $get all the GET parameters to use
param: string $uri end URL to simulate

ob_start_callback($buffer)   X-Ref
Callback for ob_start

This continues to fill our own buffer, even when some part
of the code askes for flushing the buffers

param: string $buffer

getRunning()   X-Ref
Access the TestRequest from the executed code

This allows certain functions to access the TestRequest that is accessing them
to add additional info.

return: null|TestRequest the currently executed request if any

addData($key, $value)   X-Ref
Store data to be read in the response later

When called multiple times with the same key, the data is appended to this
key's array

param: string $key the identifier for this information
param: mixed $value arbitrary data to store