testphase
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Todo

Namespaces

  • Phramework
    • Exceptions
    • Testphase
      • Exceptions
    • Validate

Classes

  • Binary
  • Expression
  • Globals
  • Server
  • TestParser
  • Testphase
  • Util

Class Testphase

Namespace: Phramework\Testphase
License: Apache-2.0
Author: Xenofon Spafaridis nohponex@gmail.com
Version: 1.1.2
Located at Testphase.php

Methods summary

public
# __construct( string $url, string $method = 'GET', array $headers = [], string|null $requestBody = null, boolean $ruleJSON = false )

Parameters

$url
Request url, without the base part, (see setBase method)
$method
[Optional] HTTP request method
$headers
[Optional] HTTP request headers
$requestBody
[Optional] HTTP request body
$ruleJSON
[Optional] Response rule, expect JSON encoded response body

Throws

Phramework\Exceptions\IncorrectParametersException
When method is not correct
public true
# run( callable|null $callback = null )

Run testphase Will execute the request and apply all defined rules to validate the response

Run testphase Will execute the request and apply all defined rules to validate the response

Parameters

$callback

[Optional] Callback to execute after completing the test rules

Returns

true
On success

Throws

Exception

Uses

self::$base When url does not contain schema use base as prefix.
public
# expectStatusCode( integer|int[] $statusCode )

Set expected HTTP response Status Code

Set expected HTTP response Status Code

Parameters

$statusCode

Returns


$this

See

http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
public
# expectResponseHeader( array[]|object $ruleHeaders )

Add expected response header

Add expected response header

Parameters

$ruleHeaders

Returns


$this

Throws

Exception
When $ruleHeaders is not an array
public
# expectJSON( boolean $flag = true )

Set rule, expect JSON encoded response body. When true it will throw an error if the response is not a valid JSON. NOTE ruleObjects only works with this flag set to true

Set rule, expect JSON encoded response body. When true it will throw an error if the response is not a valid JSON. NOTE ruleObjects only works with this flag set to true

Parameters

$flag
[Optional] Value of the flag, default is true

Returns


$this
public
# expectObject( BaseValidator $object )

Object validator, as an additional set of rules to validate the response.

Object validator, as an additional set of rules to validate the response.

Parameters

$object
Validator object

Returns


$this
public static
# setBase( string $base )

Set base API url

Set base API url

Parameters

$base
public static string
# getBase( )

Get base API url

Get base API url

Returns

string
public mixed
# getResponseStatusCode( )

Get the value of Response Status Code

Get the value of Response Status Code

Returns

mixed
public array
# getResponseHeaders( )

Get the value of Response Headers

Get the value of Response Headers

Returns

array
public string
# getResponseBody( )

Get the value of Response Body

Get the value of Response Body

Returns

string
public static string
# getVersion( )

Get library's version

Get library's version

Returns

string

Uses

Doc comments of Testphase class to extract version tag

Constants summary

integer REQUEST_EMPTY_FLAG
# 0
integer REQUEST_BINARY
# 1
integer REQUEST_NOT_URL_ENCODED
# 2

Properties summary

public static integer $SETTING_CURLOPT_CONNECTTIMEOUT

Setting CURLOPT_CONNECTTIMEOUT - timeout for the connect phase Pass a long. It should contain the maximum time in seconds that you allow the connection phase to the server to take. This only limits the connection phase, it has no impact once it has connected. Set to zero to switch to the default built-in connection timeout - 300 seconds. Default timeout is 300.

Setting CURLOPT_CONNECTTIMEOUT - timeout for the connect phase Pass a long. It should contain the maximum time in seconds that you allow the connection phase to the server to take. This only limits the connection phase, it has no impact once it has connected. Set to zero to switch to the default built-in connection timeout - 300 seconds. Default timeout is 300.

See

CURLOPT_CONNECTTIMEOUT
# 300
public static integer $SETTING_CURLOPT_TIMEOUT

Setting CURLOPT_TIMEOUT - set maximum time the request is allowed to take

Setting CURLOPT_TIMEOUT - set maximum time the request is allowed to take

Pass a long as parameter containing timeout - the maximum time in seconds that you allow the libcurl transfer operation to take. Normally, name lookups can take a considerable time and limiting operations to less than a few minutes risk aborting perfectly normal operations. This option may cause libcurl to use the SIGALRM signal to timeout system calls. Default timeout is 0 (zero) which means it never times out during transfer.

See

CURLOPT_TIMEOUT
# 0
testphase API documentation generated by ApiGen