我正在關注2.1版的官方Zend Framework 2教程。在Unit Testing部分,在這裏我應該跑在模塊/應用/測試PHPUnit的我遇到了以下問題:Zend Framework 2教程:模塊(應用程序)無法初始化
[email protected]:~/Desktop/zf2-tutorial/module/Application/test$ phpunit
PHPUnit 3.7.13 by Sebastian Bergmann.
Configuration read from /home/user/Desktop/zf2-tutorial/module/Application/test/phpunit.xml.dist
E
Time: 0 seconds, Memory: 4.00Mb
There was 1 error:
1) ApplicationTest\Controller\IndexControllerTest::testIndexActionCanBeAccessed
Zend\ModuleManager\Exception\RuntimeException: Module (Application) could not be initialized.
/home/user/Desktop/zf2-tutorial/vendor/zendframework/zendframework/library/Zend/ModuleManager/ModuleManager.php:140
/home/user/Desktop/zf2-tutorial/vendor/zendframework/zendframework/library/Zend/ModuleManager/ModuleManager.php:81
/home/user/Desktop/zf2-tutorial/vendor/zendframework/zendframework/library/Zend/EventManager/EventManager.php:460
/home/user/Desktop/zf2-tutorial/vendor/zendframework/zendframework/library/Zend/EventManager/EventManager.php:204
/home/user/Desktop/zf2-tutorial/vendor/zendframework/zendframework/library/Zend/ModuleManager/ModuleManager.php:100
/home/user/Desktop/zf2-tutorial/vendor/zendframework/zendframework/library/Zend/Mvc/Application.php:239
/home/user/Desktop/zf2-tutorial/vendor/zendframework/zendframework/library/Zend/Test/PHPUnit/Controller/AbstractControllerTestCase.php:146
/home/user/Desktop/zf2-tutorial/vendor/zendframework/zendframework/library/Zend/Test/PHPUnit/Controller/AbstractControllerTestCase.php:173
/home/user/Desktop/zf2-tutorial/vendor/zendframework/zendframework/library/Zend/Test/PHPUnit/Controller/AbstractControllerTestCase.php:193
/home/user/Desktop/zf2-tutorial/vendor/zendframework/zendframework/library/Zend/Test/PHPUnit/Controller/AbstractControllerTestCase.php:236
/home/user/Desktop/zf2-tutorial/module/Application/test/ApplicationTest/Controller/IndexControllerTest.php:20
FAILURES!
Tests: 1, Assertions: 0, Errors: 1.
我從教程複製IndexControllerTest.php的內容。
<?php
namespace ApplicationTest\Controller;
use Zend\Test\PHPUnit\Controller\AbstractHttpControllerTestCase;
class IndexControllerTest extends AbstractHttpControllerTestCase
{
public function setUp()
{
$this->setApplicationConfig(
include '/home/user/Desktop/zf2-tutorial/config/application.config.php'
);
parent::setUp();
}
public function testIndexActionCanBeAccessed()
{
$this->dispatch('/'); // this is line 20
$this->assertResponseStatusCode(200);
$this->assertModule('application');
$this->assertControllerName('application_index');
$this->assertControllerClass('IndexController');
$this->assertMatchedRouteName('home');
}
}
我不知道爲什麼應用程序不會初始化,我將不勝感激任何指針。
我的問題是我在我的模塊文件夾和文件中的權限。 (我在Ubuntu PC上) – leticia