0
當我試圖運行在我的新項目的測試,包括目錄。該目錄佈局如下:PHPUnit的嘗試給予空後綴
src/ (project's code here)
test/
EviType/
Main.php
phpunit.xml
composer.json
PHPUnit的安裝與作曲家(所謂的每個項目的依賴):
{
"require-dev": {
"phpunit/phpunit": ">=3.7.5"
},
}
我跑composer install/update
與--dev
選項。
PHPUnit的配置定義與簡約test/phpunit.xml
:
<?xml version="1.0" encoding="utf-8"?>
<phpunit colors="true">
<testsuites>
<testsuite>
<directory suffix="">EviType</directory>
</testsuite>
</testsuites>
</phpunit>
而且在test/EviType/Main.php
測試代碼也短,因爲它可以:
<?php
class Main extends PHPUnit_Framework_TestCase
{
public function test()
{
$this->assertTrue(true);
}
}
所以,當我運行的PHPUnit:
php54 -C vendor/bin/phpunit -c test/
(該系統具有許多PHP版本安裝,php54是我/usr/local/php54/bin/php
別名)
我得到一對夫婦整齊警告消息:
X-Powered-By: PHP/5.4.5
Content-type: text/html
<br />
<b>Warning</b>: include_once(/path/to/docs/test): failed to open stream: Success in <b>/path/to/docs/vendor/phpunit/phpunit/PHPUnit/Util/Fileloader.php</b> on line <b>92</b><br />
<br />
<b>Warning</b>: include_once(): Failed opening '/path/to/docs/test' for inclusion (include_path='/path/to/docs/vendor/phpunit/phpunit/:/path/to/docs/vendor/phpunit/phpunit/../../symfony/yaml:/path/to/docs/vendor/phpunit/phpunit/vendor/phpunit/php-text-template/:/path/to/docs/vendor/phpunit/phpunit/vendor/phpunit/php-token-stream/:/path/to/docs/vendor/phpunit/phpunit/vendor/phpunit/php-file-iterator/:/path/to/docs/vendor/phpunit/phpunit/vendor/phpunit/php-code-coverage/:/path/to/docs/vendor/phpunit/phpunit/vendor/phpunit/php-timer/:/path/to/docs/vendor/phpunit/phpunit/vendor/phpunit/phpunit-mock-objects/:.:/usr/local/php54/lib/php') in <b>/path/to/docs/vendor/phpunit/phpunit/PHPUnit/Util/Fileloader.php</b> on line <b>92</b><br />
<br />
<b>Warning</b>: include_once(/path/to/docs/test/EviType): failed to open stream: Success in <b>/path/to/docs/vendor/phpunit/phpunit/PHPUnit/Util/Fileloader.php</b> on line <b>92</b><br />
<br />
<b>Warning</b>: include_once(): Failed opening '/path/to/docs/test/EviType' for inclusion (include_path='/path/to/docs/vendor/phpunit/phpunit/:/path/to/docs/vendor/phpunit/phpunit/../../symfony/yaml:/path/to/docs/vendor/phpunit/phpunit/vendor/phpunit/php-text-template/:/path/to/docs/vendor/phpunit/phpunit/vendor/phpunit/php-token-stream/:/path/to/docs/vendor/phpunit/phpunit/vendor/phpunit/php-file-iterator/:/path/to/docs/vendor/phpunit/phpunit/vendor/phpunit/php-code-coverage/:/path/to/docs/vendor/phpunit/phpunit/vendor/phpunit/php-timer/:/path/to/docs/vendor/phpunit/phpunit/vendor/phpunit/phpunit-mock-objects/:.:/usr/local/php54/lib/php') in <b>/path/to/docs/vendor/phpunit/phpunit/PHPUnit/Util/Fileloader.php</b> on line <b>92</b><br />
PHPUnit 3.7.14 by Sebastian Bergmann.
Configuration read from /path/to/docs/test/phpunit.xml
.
Time: 0 seconds, Memory: 2.50Mb
OK (1 test, 1 assertion)
斷言報告讓我很開心,但我不明白爲什麼它甚至試圖include目錄:
include_once(/path/to/docs/test)
以及什麼神祕failed to open stream: Success
條款的含義。它似乎是一個php bug,但它應該像幾年前一樣修復。
設置是這樣的:
<php>
<ini name="display_errors" value="0"/>
</php>
使這些警告消失,但我覺得有PHPUnit中安裝一個更深刻的問題挖出來。
有什麼建議嗎?
哦,我現在看到的,我真的應該。謝謝你解決這個問題! 我認爲這是PHPUnit的問題。無論給出什麼後綴,包括目錄都不是正確的事情。 – 2013-03-20 20:25:15