Response header PHPUnit Constraint

uses
category Zend
package Zend_Test
subpackage PHPUnit
copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
license New BSD License

 Methods

Constructor; setup constraint state

__construct() : void

Evaluate an object to see if it fits the constraints

evaluate($response, $assertType = '', $variable = FALSE) : boolean

Parameters

$response

$assertType

$variable

Returns

booleanNOTE: Drastic changes up to PHPUnit 3.5.15 this was: public function evaluate($other, $assertType = null) In PHPUnit 3.6.0 they changed the interface into this: public function evaluate($other, $description = '', $returnResult = FALSE) We use the new interface for PHP-strict checking, but emulate the old one

Report Failure

fail($other, $description, \SebastianBergmann\Comparator\ComparisonFailure $cannot_be_used = NULL) : void
see for implementation details

Parameters

$other

$description

$cannot_be_used

Exceptions

\PHPUnit_Framework_ExpectationFailedException NOTE: Drastic changes up to PHPUnit 3.5.15 this was: public function fail($other, $description, $not = false) In PHPUnit 3.6.0 they changed the interface into this: protected function fail($other, $description, PHPUnit_Framework_ComparisonFailure $comparisonFailure = NULL) We use the new interface for PHP-strict checking NOTE 2: Interface changed again in PHPUnit 4.1.0 because of refactoring to SebastianBergmann\Comparator

Indicate negative match

setNegate(boolean $flag = true) : void

Parameters

$flag

boolean

Complete implementation

toString() : string

Returns

string

Compare response code for positive match

_code(\Zend_Controller_Response_Abstract $response, integer $code) : boolean

Parameters

$response

\Zend_Controller_Response_Abstract

$code

integer

Returns

boolean

Retrieve response code

_getCode(\Zend_Controller_Response_Abstract $response) : integer

Parameters

$response

\Zend_Controller_Response_Abstract

Returns

integer

Retrieve response header

_getHeader(\Zend_Controller_Response_Abstract $response, string $header) : string | null

Parameters

$response

\Zend_Controller_Response_Abstract

$header

string

Returns

stringnull

Positive check for response header presence

_header(\Zend_Controller_Response_Abstract $response, string $header) : boolean

Parameters

$response

\Zend_Controller_Response_Abstract

$header

string

Returns

boolean

Positive check for header contents matching pattern

_headerContains(\Zend_Controller_Response_Abstract $response, string $header, string $match) : boolean

Parameters

$response

\Zend_Controller_Response_Abstract

$header

string

$match

string

Returns

boolean

Positive check for header contents matching regex

_headerRegex(\Zend_Controller_Response_Abstract $response, string $header, string $pattern) : boolean

Parameters

$response

\Zend_Controller_Response_Abstract

$header

string

$pattern

string

Returns

boolean

Compare response code for negative match

_notCode(\Zend_Controller_Response_Abstract $response, integer $code) : boolean

Parameters

$response

\Zend_Controller_Response_Abstract

$code

integer

Returns

boolean

Negative check for response header presence

_notHeader(\Zend_Controller_Response_Abstract $response, string $header) : boolean

Parameters

$response

\Zend_Controller_Response_Abstract

$header

string

Returns

boolean

Negative check for header contents matching pattern

_notHeaderContains(\Zend_Controller_Response_Abstract $response, string $header, string $match) : boolean

Parameters

$response

\Zend_Controller_Response_Abstract

$header

string

$match

string

Returns

boolean

Negative check for header contents matching regex

_notHeaderRegex(\Zend_Controller_Response_Abstract $response, string $header, string $pattern) : boolean

Parameters

$response

\Zend_Controller_Response_Abstract

$header

string

$pattern

string

Returns

boolean

 Properties

 

Actual response code

$_actualCode : integer

Default

null
 

Current assertion type

$_assertType : string

Default

null
 

Available assertion types

$_assertTypes : array

Default

array(self::ASSERT_RESPONSE_CODE, self::ASSERT_HEADER, self::ASSERT_HEADER_CONTAINS, self::ASSERT_HEADER_REGEX)
 

Response code

$_code : integer

Default

200
 

Header

$_header : string

Default

null
 

pattern against which to compare header content

$_match : string

Default

null
 

Whether or not assertion is negated

$_negate : boolean

Default

false

 Constants

 

ASSERT_HEADER

ASSERT_HEADER = 'assertHeader' 
 

ASSERT_HEADER_CONTAINS

ASSERT_HEADER_CONTAINS = 'assertHeaderContains' 
 

ASSERT_HEADER_REGEX

ASSERT_HEADER_REGEX = 'assertHeaderRegex' 
 

ASSERT_RESPONSE_CODE

ASSERT_RESPONSE_CODE = 'assertResponseCode'