<?php
 
/**
 
 * $Id: AdvancedQuery.php 1631 2007-05-12 22:40:28Z matthieu $
 
 */
 
if (!class_exists('Test_Google_AdvancedQuery')) {
 
    if (!defined('__CLASS_PATH__')) {
 
        define('__CLASS_PATH__', realpath(dirname(__FILE__) . '/../../'));
 
    }
 
    require_once __CLASS_PATH__ . '/Autoload.php';
 
    /**
 
     * test class for google package
 
     * @package google
 
     * @subpackage unit_test_case
 
     */
 
    class Test_Google_AdvancedQuery extends Test_Google_Query
 
    {
 
        /**
 
        * default constructor
 
        * @access public
 
        * @return void
 
        */
 
        public function __construct()
 
        {
 
            parent :: __construct();
 
            $this->deleteLocalPatternFile();
 
        }
 
        /**
 
         * prepare test
 
         * @access public
 
         * @return void
 
         */
 
        public function setUp()
 
        {
 
            $this->_analysedObject = new Google_AdvancedQuery();
 
            $this->_analysedObject->setSentence(self :: __KEYWORDS__);
 
        }
 
        /**
 
         * @access public
 
         * @return void
 
         */
 
        public function tearDown()
 
        {
 
            $this->deleteLocalPatternFile();
 
        }
 
        /**
 
         * clean the local pattern file
 
         * @acess private
 
         * @return void
 
         * @throws Exception
 
         */
 
        private function deleteLocalPatternFile()
 
        {
 
            $patternFile = Google_AdvancedQuery :: getFilePattern();
 
            if (file_exists($patternFile)) {
 
                if (!unlink($patternFile)) {
 
                    throw new Exception('Cannot clean the previous pattern file: ' . $patternFile);
 
                }
 
            }
 
        }
 
        /**
 
         * check if configuration url is valid
 
         * @access public
 
         * @return void
 
         */
 
        public function testUrlUsed()
 
        {
 
            $content = file_get_contents(Google_AdvancedQuery :: __PATTERN_REMOTE_URL__);
 
            $this->assertFalse(empty ($content), "Unable to retrieve the remote pattern at " . Google_AdvancedQuery :: __PATTERN_REMOTE_URL__ .            ".If you have updated Google_AdvancedQuery class, make sure that your url is valid. Otherwise, " .            "send me an email at [email protected] to notify me of the of the url");
 
        }
 
        /**
 
         * test if local file already exists
 
         * @access public
 
         * @return void
 
         */
 
        public function testLocalFileExists() {
 
            $this->assertTrue(file_exists(Google_AdvancedQuery :: getFilePattern()),
 
             "Unable to check ".Google_AdvancedQuery :: getFilePattern().". If testUrlUsed works fine, ensure that you have write acces in ".dirname(Google_AdvancedQuery :: getFilePattern()));
 
        }
 
    }
 
} 
 
 |