Zend_Dom_Query-based 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(string $path) : void

Parameters

$path

string

CSS selector path

Evaluate an object to see if it fits the constraints

evaluate($content, $assertType = '', $match = FALSE) : boolean

Parameters

$content

$assertType

$match

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, \PHPUnit_Framework_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

Register XPath namespaces

registerXpathNamespaces(array $xpathNamespaces) : void

Parameters

$xpathNamespaces

array

Indicate negative match

setNegate(boolean $flag = true) : void

Parameters

$flag

boolean

Whether or not path is a straight XPath expression

setUseXpath(boolean $flag = true) : \Zend_Test_PHPUnit_Constraint_DomQuery

Parameters

$flag

boolean

Returns

\Zend_Test_PHPUnit_Constraint_DomQuery

Complete implementation

toString() : string

Returns

string

Determine if content count matches criteria

_countContent(\Zend_Dom_Query_Result $result, integer $test, string $type) : boolean

Parameters

$result

\Zend_Dom_Query_Result

$test

integer

Value against which to test

$type

string

assertion type

Returns

boolean

Get node content, minus node markup tags

_getNodeContent(\DOMNode $node) : string

Parameters

$node

\DOMNode

Returns

string

Check to see if content is matched in selected nodes

_matchContent(\Zend_Dom_Query_Result $result, string $match) : boolean

Parameters

$result

\Zend_Dom_Query_Result

$match

string

Content to match

Returns

boolean

Check to see if content is NOT matched in selected nodes

_notMatchContent(\Zend_Dom_Query_Result $result, string $match) : boolean

Parameters

$result

\Zend_Dom_Query_Result

$match

string

Returns

boolean

Check to see if content is NOT matched by regex in selected nodes

_notRegexContent(\Zend_Dom_Query_Result $result, string $pattern) : boolean

Parameters

$result

\Zend_Dom_Query_Result

$pattern

string

Returns

boolean

Check to see if content is matched by regex in selected nodes

_regexContent(\Zend_Dom_Query_Result $result, string $pattern) : boolean

Parameters

$result

\Zend_Dom_Query_Result

$pattern

string

Returns

boolean

 Properties

 

Current assertion type

$_assertType : string

Default

null
 

Available assertion types

$_assertTypes : array

Default

array(self::ASSERT_QUERY, self::ASSERT_CONTENT_CONTAINS, self::ASSERT_CONTENT_REGEX, self::ASSERT_CONTENT_COUNT, self::ASSERT_CONTENT_COUNT_MIN, self::ASSERT_CONTENT_COUNT_MAX)
 

Content being matched

$_content : string

Default

null
 

Whether or not assertion is negated

$_negate : boolean

Default

false
 

CSS selector or XPath path to select against

$_path : string

Default

null
 

Whether or not to use XPath when querying

$_useXpath : boolean

Default

false
 

XPath namespaces

$_xpathNamespaces : array

Default

array()

 Constants

 

ASSERT_CONTENT_CONTAINS

ASSERT_CONTENT_CONTAINS = 'assertQueryContentContains' 
 

ASSERT_CONTENT_COUNT

ASSERT_CONTENT_COUNT = 'assertQueryCount' 
 

ASSERT_CONTENT_COUNT_MAX

ASSERT_CONTENT_COUNT_MAX = 'assertQueryCountMax' 
 

ASSERT_CONTENT_COUNT_MIN

ASSERT_CONTENT_COUNT_MIN = 'assertQueryCountMin' 
 

ASSERT_CONTENT_REGEX

ASSERT_CONTENT_REGEX = 'assertQueryContentRegex' 
 

ASSERT_QUERY

ASSERT_QUERY = 'assertQuery'