我在Ubuntu 12.04下的單元測試Zend-Framework應用程序時遇到了問題。該項目的結構,而模型定義爲以下ZF-Autoloader在Ubuntu上的UnitTests中不起作用
./application
./models
./DbTable
./ProjectStatus.php (Application_Model_DbTable_ProjectStatus)
./Mappers
./ProjectStatus.php (Application_Model_Mapper_ProjectStatus)
./ProjectStatus.php (Application_Model_ProjectStatus)
這裏的問題是與特定的Zend - 自動加載默認的Zend的應用程序。命名約定在這裏出現,文件夾映射器加載所有類_Mapper但不是_Mappers。這是迄今爲止的一些內部Zend行爲。
在我的Windows機器上,phpunit運行時沒有任何問題,試圖啓動所有這些類。
在我的Ubuntu機器但是與其上運行詹金斯,PHPUnit的未能找到合適的課程給我下面的錯誤出現
Fatal error: Class 'Application_Model_Mapper_ProjectStatus' not found
in /var/lib/jenkins/jobs/PAM/workspace/tests/application/models/Mapper/ProjectStatusTest.php
on line 39
的錯誤真的是在Zend - 自動加載不從加載Ubuntu的機器,但我不知道如何或爲什麼這個工程。問題仍然存在,爲什麼這是。我想我已經仔細檢查了與zend自動加載的東西的每一個接觸點,但我無法弄清楚這一點。我會粘貼 - 從我的觀點來看相關的片段 - 並希望你們中的任何人對此有所瞭解。
詹金斯片段爲PHPUnit的
<target name="phpunit" description="Run unit tests with PHPUnit">
<exec executable="phpunit" failonerror="true">
<arg line="--configuration '${basedir}/tests/phpunit.xml' --coverage-clover '${basedir}/build/logs/clover.xml' --coverage-html '${basedir}/build/coverage/.' --log-junit '${basedir}/build/logs/junit.xml'" />
</exec>
</target>
./tests/phpunit.xml
<phpunit bootstrap="./bootstrap.php">
... this shouldn't be of relevance ...
</phpunit>
./tests/bootstrap.php
<?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', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'testing'));
// 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();
任何幫助將不勝感激。
這就是它歸結到的。 Windows是的,Unix沒有應該讓我直接不區分大小寫......感謝您指出這一點。不,應用程序不需要在我的情況下引導。對於測試模型,不需要引導應用程序,自動加載器就足夠了。對於測試控制器,我在測試之前引導應用程序以準備好乾淨的「孤獨」應用程序。 **再次感謝!** – Sam