public function testExtend() { $newMethods = array('newMethod1' => array($this, 'callback1'), 'newMethod2' => array($this, 'callback2')); phpQuery::extend('phpQueryObject', $newMethods); $doc = phpQuery::newDocumentXML("<div/>"); $this->assertTrue($doc->newMethod1() == $doc, '$doc->newMethod1 == $doc'); $this->assertTrue($doc->newMethod2() == "callback2", '$doc->newMethod1 == "callback2"'); }
<?php require_once '../phpQuery/phpQuery.php'; phpQuery::$debug = true; phpQuery::extend('WebBrowser'); phpQuery::$ajaxAllowedHosts[] = 'gmail.com'; phpQuery::$ajaxAllowedHosts[] = 'google.com'; phpQuery::$ajaxAllowedHosts[] = 'www.google.com'; phpQuery::$ajaxAllowedHosts[] = 'www.google.pl'; phpQuery::$ajaxAllowedHosts[] = 'mail.google.com'; // Google search results if (0) { phpQuery::$plugins->browserGet('http://google.com/', 'success1'); /** * * @param $pq phpQueryObject * @return unknown_type */ function success1($pq) { print 'success1 callback'; $pq->WebBrowser('success2')->find('input[name=q]')->val('phpQuery')->parents('form')->submit(); } /** * * @param $html phpQueryObject * @return unknown_type */ function success2($pq) { print 'success2 callback';