0

在我的应用程序中,我只在测试时遇到了这个奇怪的错误,我还没有测试我的 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();

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

4

1 回答 1

1

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

于 2013-10-23T14:02:24.280 回答