<?php
/**
* $Id: Google.class.php 562 2006-09-28 16:38:53Z matthieu $
*/
if (!class_exists('Test_Google_Query')) {
if (!defined('__CLASS_PATH__')) {
define('__CLASS_PATH__', realpath(dirname(__FILE__) . '/../../'));
}
if (!defined('__SIMPLETEST_PATH__')) {
define('__SIMPLETEST_PATH__', realpath(__CLASS_PATH__ . '/simpletest/'));
}
require_once __SIMPLETEST_PATH__ . '/shell_tester.php';
require_once __SIMPLETEST_PATH__ . '/reporter.php';
require_once __CLASS_PATH__ . '/Autoload.php';
/**
* test class for google package
* @package google
* @subpackage unit_test_case
*/
class Test_Google_Query extends ShellTestCase {
const __KEYWORDS__ = 'php';
/**
* @var Google_Query : the google Query object analysed
* @access protected
*/
protected $_analysedObject = null;
/**
* default constructor
* @access public
* @return void
*/
public function __construct() {
parent :: __construct();
}
public function setUp() {
$this->_analysedObject = new Google_Query();
$this->_analysedObject->setSentence(self :: __KEYWORDS__);
}
/**
* test the get link method
* @acces public
* @return void
*/
public function testGetLink() {
$this->_testGetLinkContent($this->_analysedObject);
}
/**
* test the content return by the getLink method
* @access private
* @param Google_Query $query
* @return void
*/
private function _testGetLinkContent(Google_Query $query) {
$this->assertTrue(($query->getLink() != ''), 'Unexpected getLink result: result seems to be invalid. check source code integrity');
}
/**
* test the number of results found return by the getResult method
* @access private
* @param Google_Query $query
* @return void
*/
private function _testGetLinkResult(Google_Query $query) {
$this->assertTrue(($query->getResults() > 0), 'It is really amazing that google doesn t found some results. Pattern must have change. please send a notification at matthieu@phplibrairies.com that google generated has been updated');
}
/**
* test the get result method
* @acces public
* @return void
*/
public function testGetResult() {
$this->_testGetLinkResult($this->_analysedObject);
}
}
}
|