如何在Windows Server上与phpdbg一起使用PHP代码覆盖率? [英] How to get the PHP Code Coverage working with phpdbg on a Windows Server?

查看:103
本文介绍了如何在Windows Server上与phpdbg一起使用PHP代码覆盖率?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于我仍然有 PHPUnit/PHP的问题代码覆盖率和Xdebug ,我决定尝试另一种方式-使用 phpdbg .

Since I still have troubles with PHPUnit / PHP Code Coverage and Xdebug, I decided to try it another way -- with phpdbg.

我以 hier 的身份完成了操作如图所示.在CMD和Git Bash中都尝试过,但是结果是一样的,但是失败了:

I did it as hier shown. Tried in CMD and also in Git Bash, but the result is the same, it fails:

$ composer info | grep "phpunit"
phpunit/php-code-coverage           4.0.0  Library that provides collectio...
phpunit/php-file-iterator           1.4.1  FilterIterator implementation t...
phpunit/php-text-template           1.2.1  Simple template engine.
phpunit/php-timer                   1.0.8  Utility class for timing
phpunit/php-token-stream            1.4.8  Wrapper around PHP's tokenizer ...
phpunit/phpunit                     5.4.6  The PHP Unit Testing framework.
phpunit/phpunit-mock-objects        3.2.3  Mock Object library for PHPUnit

$ phpdbg -qrr ./vendor/bin/phpunit -v

dir=$(d=${0%[/\\]*}; cd "$d"; cd "../phpunit/phpunit" && pwd)

# See if we are running in Cygwin by checking for cygpath program
if command -v 'cygpath' >/dev/null 2>&1; then
        # Cygwin paths start with /cygdrive/ which will break windows PHP,
        # so we need to translate the dir path to windows format. However
        # we could be using cygwin PHP which does not require this, so we
        # test if the path to PHP starts with /cygdrive/ rather than /usr/bin
        if [[ $(which php) == /cygdrive/* ]]; then
                dir=$(cygpath -m "$dir");
        fi
fi

dir=$(echo $dir | sed 's/ /\ /g')
"${dir}/phpunit" "$@"

如何获得组合PHPUnit& PHP代码覆盖率和在Windows Server上运行phpdbg?

推荐答案

在Windows下,似乎vendor/bin中的文件实际上是批处理文件,调用了原始文件(而不是phpdbg可以理解的php文件).

Under Windows it seems that files in vendor/bin are actually batch files, invoking the original file (and not php files which phpdbg will understand).

在这种情况下:

dir=$(d=${0%[/\\]*}; cd "$d"; cd "../phpunit/phpunit" && pwd)
                                  ^^^^^^^^^^^^^^^^^^
"${dir}/phpunit" "$@"
 ^^^^^^^^^^^^^^

../phpunit/phpunit/phpunit(此路径相对于vendor/bin);因此实际文件位于vendor/phpunit/phpunit/phpunit.

i.e. ../phpunit/phpunit/phpunit (this path is relative to vendor/bin); thus the actual file is at vendor/phpunit/phpunit/phpunit.

然后您可以直接通过phpdbg -qrr vendor/phpunit/phpunit/phpunit调用它.

And you can invoke it directly via phpdbg -qrr vendor/phpunit/phpunit/phpunit then.

这篇关于如何在Windows Server上与phpdbg一起使用PHP代码覆盖率?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆