简体   繁体   中英

PHPUNIT weird error

In my application I have this weird error when testing only , I am not testing any classes in my Repo folder yet but have this:

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

My user Repo is:

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);
    }

My cache class is:

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;
    }
}

My testing bootstrap is:

<?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();

I Have tried to change the Cache class by having to instantiate it but I get the same result... My Database class has the exact structure but I haven`t gotten this in the past, now that I advanced in development I wanted to make tests and the error appeared

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM