PHPUNIT奇怪的错误


PHPUNIT weird error

在我的应用程序中,仅在测试时出现此奇怪错误,我尚未测试Repo文件夹中的任何类,但有以下内容:

Call to undefined method Application_Model_Cache::getInstance() in C:'wamp'www'truCrowd_dev'application'models'Repo'User.php on line 12

我的用户存储库是:

class Application_Model_Repo_User
{
    private $_database;
    private $_cache   ;
    public function __construct()
    {
        $this->_database   = Application_Model_Database::getInstance();
        $this->_cache      = Application_Model_Cache::getInstance();
        $this->_longCache  = Application_Model_Cache::getInstance(604800);
    }

我的缓存类是:

class Application_Model_Cache
{
    public static function getInstance($_expiration = 7200)
    {  
        $frontend= array(
        'lifetime' => $_expiration,
        'automatic_serialization' => true
        );
        $backend= array(
        'cache_dir' => './cache/',
        );
        $cache = Zend_Cache::factory('Output',
            'File',
            $frontend,
            $backend
        );
        return $cache;
    }
}

我的测试引导程序是:

<?php
// Define path to application directory
defined('APPLICATION_PATH')
    || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
// Define application environment
defined('APPLICATION_ENV') || define('APPLICATION_ENV', 'production');
// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
    realpath(APPLICATION_PATH . '/../library'),
    get_include_path(),
)));
require_once 'Zend/Loader/Autoloader.php';
Zend_Loader_Autoloader::getInstance();

我试图通过实例化来更改 Cache 类,但我得到了相同的结果......我的数据库类具有确切的结构,但我过去没有得到这个,现在我在开发中取得了进展,我想进行测试,但出现了错误

您应该检查Application_Model_Cache类是否在任何测试中被模拟,以及在调用不存在的方法时是否未使用模拟。