gpt4 book ai didi

zend-framework - PHPUnit 和 Zend Framework 的代码覆盖失败

转载 作者:行者123 更新时间:2023-12-04 06:53:54 25 4
gpt4 key购买 nike

我对 PHPunit 和 zend 框架中的代码覆盖率报告有一些疑问。每当我运行 phpunit 测试时,代码覆盖率都会失败并返回以下消息:


PHPUnit 3.4.15 by Sebastian Bergmann.

I.......III.I................................IIIIIIIIIIIIIII 60 / 93
IIII....I....I..II..II.....IIIIII

Time: 4 seconds, Memory: 22.25Mb

OK, but incomplete or skipped tests!
Tests: 93, Assertions: 174, Incomplete: 36.

Generating code coverage report, this may take a moment.PHP Fatal error: Cannot redeclare class Klunde_Auth in /Users/kristianlunde/workspaces/private/klunde/Library/Klunde/Auth.php on line 9

Fatal error: Cannot redeclare class Klunde_Auth in /Users/kristianlunde/workspaces/private/klunde/Library/Klunde/Auth.php on line 9

My phpunit.xml file looks like this:


<phpunit bootstrap="./application/bootstrap.php" colors="true">
<testsuite name="Klunde">
<directory>./application/</directory>
<directory>./Library/Klunde</directory>
</testsuite>

<filter>
<whitelist>
<directory suffix=".php">../application</directory>
<directory suffix=".php">../Library/Klunde</directory>
<exclude>
<directory suffix=".phtml">../application/</directory>
<file>../application/Bootstrap.php</file>
<file>../application/controllers/ErrorController.php</file>
</exclude>
</whitelist>
</filter>

<logging>
<log type="coverage-html" target="./log/report" charset="UTF-8" yui="true"
highlight="true" lowUpperBound="50" highLowerBound="80" />

<log type="testdox-html" target="./log/testdox.html" />
</logging>
</phpunit>

I did a

var_dump(get_included_files());

在 Auth 文件的顶部,它确实在失败之前多次尝试包含该文件。

我也曾尝试删除 Klunde_Auth.php 文件,只是想看看它是否是一个文件的问题,但随后在 Library/Klunde 目录中的下一个文件上触发了错误。

我正在运行 OSX Snow Leopard,带有 PHP 5.3.1、XDebug 2.1.0beta3 和 PHPUnit 3.4.15

我们将不胜感激所有的帮助和帮助。

谢谢。

最佳答案

添加一个debug_print_backtrace()在类声明本身开始之前调用 Klunde_Auth.php 的顶部。

然后再次运行测试套件,现在您将在每次包含文件时看到整个回溯,这应该可以帮助您弄清楚它被包含两次的内容/来源。

关于zend-framework - PHPUnit 和 Zend Framework 的代码覆盖失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3434086/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com