php - 使用 composer.json 中定义的 Composer 脚本,如何显示 phpunit 颜色?

标签 php phpunit composer-php

语境

我正在使用我的 composer.json 中定义的 Composer 脚本文件以在我的应用程序中运行单元测试。

我的 composer.json :

{
    "name": "my company/my_application",
    "description": "Description of my application",
    "license": "my licence",
    "require": {
        "php": ">=5.6",
        "ext-soap": "*",
        "ext-ssh2": "*",
        "ext-curl": "*",
        "ext-zip": "*",
        "ext-pdo_mysql": "*",
        "ext-gettext": "*",
        "dusank/knapsack": "^9.0"
    },
    "require-dev": {
        "ext-mysqli": "*",
        "phpunit/phpunit": "^5.7",
        "squizlabs/php_codesniffer": "2.*"
    },
    "scripts": {
        "test-php": "vendor/bin/phpunit --colors --verbose --bootstrap tests/bootstrap.php --configuration tests/phpunit.xml",
    }
}

我的命令是:
vendor/bin/phpunit --colors --verbose --bootstrap tests/bootstrap.php --configuration tests/phpunit.xml tests/

问题

如果我运行 vendor/bin/phpunit --colors --verbose --bootstrap tests/bootstrap.php --configuration tests/phpunit.xml tests/在终端内,我可以看到彩色输出。但是如果我使用 Composer 运行它,我看不到任何颜色。



使用 composer.json 中定义的 Composer 脚本,如何显示 phpunit 颜色?

最佳答案

要强制 phpunit 在任何情况下显示颜色,添加 =always--color参数。


vendor/bin/phpunit --colors=always --verbose --bootstrap tests/bootstrap.php --configuration tests/phpunit.xml tests/

在我的 composer.json文件,我可以看到颜色。

关于php - 使用 composer.json 中定义的 Composer 脚本,如何显示 phpunit 颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44550254/

相关文章:

php - MVC和依赖注入(inject),被迫使用单例Controller?

php - 删除无效/不完整的多字节字符

php - IE8 不允许下拉菜单

php - CakePHP/Mysql 插入 UTF-8

laravel - 使用 PHPUnit 测试时是否可以隐藏堆栈跟踪?

Laravel 安装错误 : "touch(): Utime failed: Permission denied"

laravel - 为什么 composer 不在/usr/bin 中全局安装 Laravel?

unit-testing - 如何编写集成测试以与外部 API 交互?

unit-testing - Zend Framework 2 & PHPUnit - 模拟 Zend\Db\Adapter\Adapter 类

laravel - .gitignore 不适用于被忽略文件夹的子文件夹