-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy path46SelectRegExp.php
51 lines (46 loc) · 1.4 KB
/
46SelectRegExp.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
/**
* assertSelectRegExp(
* array $selector,
* string $pattern,
* integer $count,
* mixed $actual[,
* string $message = '',
* boolean $isHtml = TRUE]
* )
* Reports an error identified by $message if the CSS selector $selector
* does not match $count elements in the DOMNode $actual with a value that matches $pattern.
*
* $count can be one of the following types:
*
* boolean: Asserts for presence of elements matching the selector (TRUE) or
* absence of elements (FALSE).
* integer: Asserts the count of elements.
* array: Asserts that the count is in a range specified by using <, >, <=, and >= as keys.
*
*/
class SelectRegExpTest extends PHPUnit_Framework_TestCase
{
protected function setUp()
{
$this->xml = new DomDocument;
$this->xml->loadXML('<foo><bar>Baz</bar><bar>Baz</bar></foo>');
}
public function testAbsenceFailure()
{
$this->assertSelectRegExp('foo bar', '/Ba.*/', FALSE, $this->xml);
}
public function testPresenceFailure()
{
$this->assertSelectRegExp('foo bar', '/B[oe]z]/', TRUE, $this->xml);
}
public function testExactCountFailure()
{
$this->assertSelectRegExp('foo bar', '/Ba.*/', 5, $this->xml);
}
public function testRangeFailure()
{
$this->assertSelectRegExp('foo bar', '/Ba.*/', array('>'=>6, '<'=>8), $this->xml);
}
}
?>