定制 dpi/enhanced-drupal-phpunit-results 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

dpi/enhanced-drupal-phpunit-results

Composer 安装命令:

composer require dpi/enhanced-drupal-phpunit-results

包简介

README 文档

README

Codecov GitHub branch checks state License

Provides tooling to improve the output of PHPUnit tests with Drupal.

After

Spotlight After

Before

Spotlight Before

Highlights

  • Command-click/control click URL to open artifact in web browser.
  • Command-click/control click file+line to open in IDE (PHPStorm / VSCode / MacVim / Emacs / Sublime Text / Textmate)
  • The URL fetched is shown.
  • drupalGet/drupalLogin/drupalLogout/htmlOutput/submitForm page loads are detected,
  • Icon shown indicating whether artifact is associated with a page load: 📄 drupalGet 🛂 drupalLogin 🥾 drupalLogout ⚡️ htmlOutput 🖍 submitForm
  • Test method is green or red depending on test pass/failure.
  • Execution stack is shown between the test method and the point of page load.
  • For direct invocations of page load from a test, a short stack is shown.

The project is intended for use with functional tests, specifically projects utilizing Drupal Test Traits. Its recommended to utilize phpunit --printer or create a new phpunit.xml to separate Kernel and Unit tests.

Tests will need to use the included trait. Out of the box this enhancement cannot be used with tests out of your control, unless base test classes are patched, such as \Drupal\Tests\BrowserTestBase.

Drupal is a registered trademark of Dries Buytaert.

Installation and setup

composer require dpi/enhanced-drupal-phpunit-results

In PHPUnit configuration files such as phpunit.xml, phpunit.xml.dist, etc, modify printerClass to reference the class from this library:

<phpunit printerClass="\dpi\EnhancedDrupalPhpunitResults\EnhancedResultPrinter" />

In base test files, replace use \Drupal\Tests\UiHelperTrait with use \dpi\EnhancedDrupalPhpunitResults\CombinedEnhancedUiHelperTrait.

Or if there are collisions,

use EnhancedUiHelperTrait {
    EnhancedUiHelperTrait::htmlOutput insteadof UiHelperTrait;
}

Configuration

Optional configuration is available.

Set these values as environment variables in the executor or phpunit.ini file.

IDE launch links

Will trigger control/command-clicks on file paths to open in an editor of choice.

Possible values:

  • emacs
  • macvim
  • phpstorm
  • sublime
  • textmate
  • vscode

export ENHANCED_RESULTS_IDE=phpstorm

<php>
    <env name="ENHANCED_RESULTS_IDE" value="phpstorm" />
</php>

IDE Launch Links

Repeat context

Will repeat the executing test at the top of the stack. Normally the executed test is only printed once at the beginning. This option will print the test in context for each drupalGet at the top of the stack. This is useful for tests with many drupalGets.

export ENHANCED_RESULTS_USE_REPEAT_CONTEXT=TRUE

<php>
    <env name="ENHANCED_RESULTS_USE_REPEAT_CONTEXT" value="TRUE" />
</php>

IDE Launch Links

Disable trimming columns to terminal width

Disable trimming file and URL text strings to terminal width. Instead strings will display untruncated.

export ENHANCED_RESULTS_DISABLE_TRIM_COLUMNS=TRUE

<php>
    <env name="ENHANCED_RESULTS_DISABLE_TRIM_COLUMNS" value="TRUE" />
</php>

Disable stacks

Disable long stacks if they are noisy

export ENHANCED_RESULTS_DISABLE_OUTPUT_STACK=TRUE

<php>
    <env name="ENHANCED_RESULTS_DISABLE_OUTPUT_STACK" value="TRUE" />
</php>

IDE Launch Links

Use sequential IDS instead of artifact numbers

Display numbers next to each drupalGet, starting from 1, relative to the current test run. Instead of artifact numbers.

export ENHANCED_RESULTS_USE_SEQUENTIAL_IDS=TRUE

<php>
    <env name="ENHANCED_RESULTS_USE_SEQUENTIAL_IDS" value="TRUE" />
</php>

Change file prefix

Changes file prefix so clickable files work, useful when used with Docker mounts or symlinks.

export ENHANCED_RESULTS_FILE_PREFIX=/home/user/www

<php>
    <env name="ENHANCED_RESULTS_FILE_PREFIX" value="/home/user/www" />
</php>

Other notes

  • Utilize Drupal's builtin BROWSERTEST_OUTPUT_BASE_URL if artifacts are accessed by a different URL by the host OS, than the test runner. This helps to resolve issues with incorrect clickable artifact URLs.

dpi/enhanced-drupal-phpunit-results 适用场景与选型建议

dpi/enhanced-drupal-phpunit-results 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3.99k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2022 年 06 月 19 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 dpi/enhanced-drupal-phpunit-results 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 dpi/enhanced-drupal-phpunit-results 我们能提供哪些服务?
定制开发 / 二次开发

基于 dpi/enhanced-drupal-phpunit-results 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 3.99k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2022-06-19