And even though it works, I still can no get configs i registered, so i don't think path is the essence of problem.
--
Location:
2009/10/12 Marcus Ramsden <mmr@ecs.soton.ac.uk>
Just a thought, it is a bit of a basic one but just to cover all of the bases. Are you defining your autoloader with an absolute path or a relative one. Here is an example where I am bootstrapping from an absolute path;class Authentication_Bootstrap{protected function _initModuleRoot(){defined("AUTHENTICATION_ROOT") || define("AUTHENTICATION_ROOT", realpath(dirname(__FILE__)));}protected function _initAutoloader(){$moduleLoader = new Zend_Loader_Autoloader_Resource(array('namespace' => 'admin','basePath' => AUTHENTICATION_ROOT));$moduleLoader->addResourceType('forms', '/forms', 'Form');$moduleLoader->addResourceType('models', '/models', 'Model');$autoloader = Zend_Loader_Autoloader::getInstance();$autoloader->pushAutoloader($moduleLoader);}// More bootstrap functions follow...}As you can see I am creating a module root constant as the first function in the bootstrap. If you are doing it relatively it may be that your test is messing up since you aren't running the application from the traditional start location in {SITE_ROOT}/public/index.php.Also it may be worth double checking that you are including your library directory in your application, unless you have installed Zend Framework using PEAR which I assume means that it is already on your include path. Either, you need includePaths.library = APPLICATION_PATH "/../library" in your application.ini, it's XML equivalent, or if you can put a set_include_path command in your initial application startup for the tests;set_include_path(implode(PATH_SEPARATOR, array(APPLICATION_PATH.'/../library',get_include_path()));On 12 Oct 2009, at 09:56, huajun qi wrote:We are trying to build a stable and easy-to-use testing system within Zend Framework.I created a module named user, and some models such as User_Model_User class under application/modules/user/models, actually made it work with your help. All models have extended Zend_Db_Table class.Now I want to test the model.I watched a great video tutorial at: http://www.zendcasts.com/unit-testing-with-the-zend-framework-with-zend_test-and-phpunit/2009/06/, and I followed it to bulid testing framework. I have written phpunit.xml, bootstrap file, controllertestcast.php, and UserTest.php file. I add a testing function:public function testCanItWork(){$this->assertTrue(true);}in UserTest.php. Everything goes well.When I try to test the model really, errors are reported that User_Model_User are not found, I include it and got another error message "Zend_Db_Table are not found",I include all required files, but still get errors: Zend_Db_Table has no adapter.I am totally confused. I don't know how to fix it.I have found that the application has been bootstraped, but why the classes I need are not autoloaded?I have read configurations and register it, set default adapter for Zend_Db_Table in application's bootstrap file, and the application are bootstraped successfully, but why I can not get it?Marcus RamsdenTechnical Project AssistantLearning Societies Laboratory, Electronics and Computer ScienceUniversity of SouthamptonRoom 3069, Building 32, Highfield CampusSouthampton SO17 1BJ------------------------------------Skype: cuscus1986
--
Location:
没有评论:
发表评论