public function testPing() { // Prepare the mocked requestHandler object $this->requestHandler->expects($this->any())->method('get')->will($this->returnValue(array(array('X-Pingback: http://www.example.com/xmlrpc.php'), ''))); $this->requestHandler->expects($this->once())->method('post')->with('http://www.example.com/xmlrpc.php', "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n<methodCall>\n" . "<methodName>pingback.ping</methodName>\n<params>\n <param>\n " . "<value>\n <string>http://original.url/with/path</string>\n " . "</value>\n </param>\n <param>\n <value>\n " . "<string>http://target.url/with/path</string>\n </value>\n " . "</param>\n</params>\n</methodCall>", array("Content-Type: text/xml", "User-Agent: Pingback-PHP 0.9", "Host: target.url"))->will($this->returnValue(array(array(), '<body><head></head></body>'))); $client = new \Pingback\Client($this->requestHandler); $this->assertEquals($client->ping('http://original.url/with/path', 'http://target.url/with/path'), null); }
<?php require __DIR__ . '/../autoload.php.dist'; // Prepare the source and target urls $siteOrigin = "http://www.mabishu.com/blog/2012/12/14/get-better-performance-" . "and-life-from-your-ssd-in-linux-based-systems/"; $siteTarget = "http://www.mabishu.com/blog/2012/12/14/object-calisthenics-write-" . "better-object-oriented-code/"; // Prepare the Pingback client $requestHandler = new Pingback\RequestHandler(); $client = new Pingback\Client($requestHandler); // Perform the pinbback call try { $client->ping($siteOrigin, $siteTarget); } catch (Pingback\Exception $e) { printf("Exception raised with code (%d) : %s\n", $e->getCode(), $e->getMessage()); }