forked from punkave/phpQuery
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_attr.php
More file actions
26 lines (23 loc) · 746 Bytes
/
Copy pathtest_attr.php
File metadata and controls
26 lines (23 loc) · 746 Bytes
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
<?php
require_once('../phpQuery/phpQuery.php');
phpQuery::$debug = true;
$testName = 'Attribute change';
$expected = 'new attr value';
$result = phpQuery::newDocumentFile('test.html')
->find('p[rel]:first')
->attr('rel', $expected);
if ($result->attr('rel') == $expected)
print "Test '{$testName}' passed :)";
else
print "Test '{$testName}' <strong>FAILED</strong> !!!";
print "\n";
$testName = 'Attribute change in iteration';
$expected = 'new attr value';
$doc = phpQuery::newDocumentFile('test.html');
foreach($doc['p[rel]:first'] as $p)
pq($p)->attr('rel', $expected);
if ($doc['p[rel]:first']->attr('rel') == $expected)
print "Test '{$testName}' passed :)";
else
print "Test '{$testName}' <strong>FAILED</strong> !!!";
print "\n";