2013-05-27 84 views
0

我是新來的單元測試,我一直在這個教程中,我發現互聯網上:PHPUnit的與Zend框架

http://blog.fedecarg.com/2008/12/27/testing-zend-framework-controllers/

我的問題是我根本無法執行所顯示的測試教程!

Ç

:\瓦帕\ WWW \ portailmg \ dev的\測試>的PHPUnit的PHPUnit 21年7月3日通過Sebastian 貝格曼。

配置在C閱讀:\ WAMP \ WWW \ portailmg \ dev的\測試\ phpunit.xml

時間:0秒,內存:4.00Mb

沒有執行的測試!

HTML格式...做

生成代碼覆蓋率報告

C:\ WAMP \ WWW \ portailmg \ dev的\測試>

我的bootstrap.php這是我編輯,因爲只有文件我有以下錯誤:

說明:那麼Zend_Loader ::那麼Zend_Loader :: registerAutoload被棄用的 1.8.0,將與2.0.0除去;使用Zend_Loader_Autoloader代替/www/zf-tutorial/library/Zend/Loader.php

我試圖與解決此問題:

This is because you have the lines: 

require_once 'Zend/Loader.php'; 
Zend_Loader::registerAutoload(); 

(or similar) somewhere in your bootstrap system. 

The easiest solution is to change them to: 

require_once 'Zend/Loader/Autoloader.php'; 
$loader = Zend_Loader_Autoloader::getInstance(); 
$loader->registerNamespace('App_'); 

Where 'App_' is the name of a directory on your include path that has classes within it that follow the Zend Framework naming convention, so change it as appropriate and add more if you need them. 

我的引導:

<?php 
error_reporting(E_ALL | E_STRICT); 
ini_set('display_startup_errors', 1); 
ini_set('display_errors', 1); 
date_default_timezone_set('Europe/London'); 

define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../applications')); 
define('APPLICATION_ENV', 'loc'); 
define('LIBRARY_PATH', realpath(dirname(__FILE__) . '/../library')); 
define('TESTS_PATH', realpath(dirname(__FILE__))); 

$_SERVER['SERVER_NAME'] = 'http://localhost'; 

$includePaths = array(LIBRARY_PATH, get_include_path()); 
set_include_path(implode(PATH_SEPARATOR, $includePaths)); 

require_once 'Zend/Loader/Autoloader.php'; 
$loader = Zend_Loader_Autoloader::getInstance(); 
$loader->registerNamespace('LIBRARY_PATH'); 

Zend_Session::$_unitTestEnabled = true; 
Zend_Session::start(); 
?> 

謝謝提前尋求幫助

回答

2

你的設置看起來不錯,但如果我沒記錯的話,zend framework 1只能工作於> = 3.5.x以上也許從3.7降級到3.5可能會有所斬獲。確保你的phpunit.xml文件安裝正確,並指向測試引導而不是你的應用程序引導。還要確保遵循單元測試名稱約定。請參閱http://phpunit.de/manual/3.5/en/index.html

+2

這是正確的,版本必須是3.5.x,這裏也請參閱[鏈接](http://stackoverflow.com/a/8389837/131664) – spankmaster79

+1

http://framework.zend.com/blog /zend-framework-1-12-4-2-1-6-and-2-2-6-released.html ZF 1.12.4及以上支持/使用phpunit 3.7 – kguest