2016-10-01 73 views
2

我在Zend框架的工作時,我已經設置了一切,但在單元測試中,我得到一個致命的錯誤:PHPUnit的:開捕致命錯誤檢測

C:\ XAMPP \ htdocs中\ Zend的\模塊\專輯\測試> phpunit PHP可捕獲的致命錯誤:傳遞給Zend \ ServiceManager \ ServiceManager :: __ construct()的Arugment 1必須是在C:\ xampp \ htdocs \ zend \ module \ Album \ test \ bootstrap.php中上線53和在C定義:\ XAMPP \ htdocs中\ Zend的\ vendorframework \ Zend的-的ServiceManager \ SRC \ ServiceManager.php上線144

bootstrap.php中52-58線:

$config = ArrayUtils::merge($baseConfig, $testConfig); 
    $serviceManager = new ServiceManager(new ServiceManagerConfig()); 
    $serviceManager->setService('ApplicationConfig', $config); 
    $serviceManager->get('ModuleManager')->loadModules(); 

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

ServiceManager.php線144-148:

public function __construct(array $config = []) 
    { 
     $this->creationContext = $this; 
     $this->configure($config = []); 
    } 

一些建議,請???

回答

1
$serviceManager = new ServiceManager(new ServiceManagerConfig()); 

Arugment 1 passed to Zend\ServiceManager\ServiceManager::__construct() must be of the type array, object given

錯誤是告訴你,ServiceManager期望一個數組作爲參數。您傳遞的參數是new ServiceManagerConfig(),這是一個對象。

這是一個版本不匹配。

zendframework/zend-servicemanager~2.0ServiceManager構造函數需要一個對象。

zendframework/zend-servicemanager~3.0ServiceManager構造函數需要一個數組。

如果您使用的是zf skeleton application,請確保您使用的是正確的版本。

+0

謝謝你的回覆...那麼我需要改變什麼來解決這個錯誤? –

+0

如果你使用的是作曲家,那麼確保它需要你想要的版本。它看起來像你可能需要2.0版本,但它取決於你的項目。 –

+0

我按照以下步驟操作,找不到我出錯的地方 https://framework.zend.com/manual/2.0/en/user-guide/unit-testing.html –