<?php //error_reporting(E_ALL); require_once '../PhpQuery/PhpQuery.php'; PhpQuery::$debug = true; PhpQuery::plugin('Scripts'); $testName = 'Scripts/example'; $doc = PhpQuery::newDocumentFile('test.html'); $testResult = 10; if ($doc->script('example', 'p')->length == $testResult) { print "Test '{$testName}' PASSED :)"; } else { print "Test '{$testName}' <strong>FAILED</strong> !!! "; print "<pre>"; var_dump($doc->whois()); print "</pre>\n"; } print "\n"; $testName = 'Scripts/gmail_login'; $testResult = 1; $url = 'http://code.google.com/p/phpquery/w/edit/MultiDocumentSupport'; //PhpQuery::ajaxAllowURL($url); $editor = PhpQuery::newDocument('<div/>')->script('google_login')->location($url); if ($editor->find('textarea#content')->length == $testResult) { print "Test '{$testName}' PASSED :)"; } else { print "Test '{$testName}' <strong>FAILED</strong> !!! "; print "<pre>"; var_dump($doc->whois()); print "</pre>\n"; }
$pq->WebBrowser('success2')->find('input[name=q]')->val('PhpQuery')->parents('form')->submit(); } /** * * @param $html PhpQueryObject * @return unknown_type */ function success2($pq) { print 'success2 callback'; print $pq->find('script')->remove()->end(); } } // Gmail login (not working...) if (0) { PhpQuery::plugin("Scripts"); PhpQuery::newDocument('<div/>')->script('google_login')->location('http://mail.google.com/')->toReference($pq); if ($pq) { print $pq->script('print_websafe'); } } // Gmail login v2 (not working...) if (0) { $browser = null; $browserCallback = new CallbackReference($browser); PhpQuery::browserGet('http://mail.google.com/', $browserCallback); if ($browser) { $browser->WebBrowser($browserCallback)->find('#Email')->val('*****@*****.**')->end()->find('#Passwd')->val('XXX')->parents('form')->submit(); if ($browser) { print $browser->script('print_websafe'); }