2012-12-28 49 views
0

我正在學習zend 2.0.6,在開始的時候。我在phpunit測試 PHPUnit 3.7.10 by Sebastian Bergmann中得到以下錯誤。Zf 2 ---- phpunit沒有測試執行錯誤

配置選自C讀:\瓦帕\ WWW \ ZF2教程\模塊\應用程序\測試\ PHPUnit的

.XML

時間:0秒,內存:4.25MB

未測試執行!

我phpunit.xml.dist是

<?xml version="1.0" encoding="UTF-8"?> 

<phpunit bootstrap="Bootstrap.php"> 
<testsuites> 
    <testsuite name="ZendSkeletonApplication"> 
     <directory>/ApplicationTest</directory> 
    </testsuite> 
</testsuites> 
</phpunit> 

自舉

<?php 
namespace ApplicationTest;//Change this namespace for your test 

use Zend\Loader\AutoloaderFactory; 
use Zend\Mvc\Service\ServiceManagerConfig; 
use Zend\ServiceManager\ServiceManager; 
use Zend\Stdlib\ArrayUtils; 
use RuntimeException; 

error_reporting(E_ALL | E_STRICT); 
chdir(__DIR__); 

class Bootstrap 
{ 
protected static $serviceManager; 
protected static $config; 
protected static $bootstrap; 

public static function init() 
{ 
    // Load the user-defined test configuration file, if it exists; otherwise, load 
    if (is_readable(__DIR__ . '/TestConfig.php')) { 
     $testConfig = include __DIR__ . '/TestConfig.php'; 
    } else { 
     $testConfig = include __DIR__ . '/TestConfig.php.dist'; 
    } 

    $zf2ModulePaths = array(); 

    if (isset($testConfig['module_listener_options']['module_paths'])) { 
     $modulePaths = $testConfig['module_listener_options']['module_paths']; 
     foreach ($modulePaths as $modulePath) { 
      if (($path = static::findParentPath($modulePath))) { 
       $zf2ModulePaths[] = $path; 
      } 
     } 
    } 

    $zf2ModulePaths = implode(PATH_SEPARATOR, $zf2ModulePaths) . PATH_SEPARATOR; 
    $zf2ModulePaths .= getenv('ZF2_MODULES_TEST_PATHS') ?: (defined('ZF2_MODULES_TEST_PATHS') ? ZF2_MODULES_TEST_PATHS : ''); 

    static::initAutoloader(); 

    // use ModuleManager to load this module and it's dependencies 
    $baseConfig = array(
     'module_listener_options' => array(
      'module_paths' => explode(PATH_SEPARATOR, $zf2ModulePaths), 
     ), 
    ); 

    $config = ArrayUtils::merge($baseConfig, $testConfig); 

    $serviceManager = new ServiceManager(new ServiceManagerConfig()); 
    $serviceManager->setService('ApplicationConfig', $config); 
    $serviceManager->get('ModuleManager')->loadModules(); 

    static::$serviceManager = $serviceManager; 
    static::$config = $config; 
} 

public static function getServiceManager() 
{ 
    return static::$serviceManager; 
} 

public static function getConfig() 
{ 
    return static::$config; 
} 

protected static function initAutoloader() 
{ 
    $vendorPath = static::findParentPath('vendor'); 

    if (is_readable($vendorPath . '/autoload.php')) { 
     $loader = include $vendorPath . '/autoload.php'; 
    } else { 
     $zf2Path = getenv('ZF2_PATH') ?: (defined('ZF2_PATH') ? ZF2_PATH : (is_dir($vendorPath . '/ZF2/library') ? $vendorPath . '/ZF2/library' : false)); 

     if (!$zf2Path) { 
      throw new RuntimeException('Unable to load ZF2. Run `php composer.phar install` or define a ZF2_PATH environment variable.'); 
     } 

     include $zf2Path . '/Zend/Loader/AutoloaderFactory.php'; 

    } 

    AutoloaderFactory::factory(array(
     'Zend\Loader\StandardAutoloader' => array(
      'autoregister_zf' => true, 
      'namespaces' => array(
       __NAMESPACE__ => __DIR__ . '/' . __NAMESPACE__, 
      ), 
     ), 
    )); 
} 

protected static function findParentPath($path) 
{ 
    $dir = __DIR__; 
    $previousDir = '.'; 
    while (!is_dir($dir . '/' . $path)) { 
     $dir = dirname($dir); 
     if ($previousDir === $dir) return false; 
     $previousDir = $dir; 
    } 
    return $dir . '/' . $path; 
} 
} 

Bootstrap::init(); 

TestConfig.php.dist是

<?php 
    return array(
     'modules' => array(
      'Application', 
     ), 
     'module_listener_options' => array(
      'config_glob_paths' => array(
       '../../../config/autoload/{,*.}{global,local}.php', 
      ), 
      'module_paths' => array(
       'module', 
       'vendor', 
      ), 
     ), 
    ); 

和變薄,如文檔--http: //framework.zend.com/manual/2.0/en/user-guide/unit-testing.html 哪裏是錯誤,我是否荷蘭國際集團不對的地方

回答

2

<directory>/ApplicationTest</directory> 

UNIX上的領先/刪除前導/指的根目錄,這是不是你想要的。即使在Windows上也不行。