定制 chr0n1x/php_codesniffer_tests 二次开发

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

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

chr0n1x/php_codesniffer_tests

最新稳定版本:2.0.0

Composer 安装命令:

composer require chr0n1x/php_codesniffer_tests

包简介

A test lib that can easily be required & used in custom PHP_CodeSniffer rulesets

README 文档

README

Fork of squizlabs/PHP_CodeSniffer, but just the AbstractSniffUnitTest class. Why?

  • I didn't want to lose any git commit history for this particular file!
  • Now in your composer.json you can just
"require": {
    "chr0n1x/php_codesniffer_tests": "1.0.0"
}

and automatically have access to AbstractSniffUnitTest in your unit tests when you require(__DIR__.'/vendor/autoload.php');

  • allows you to use phpunit xml configuration files and test locally, right in your own standards repo
  • Easy CI integration. Just composer install && ${RUN_SUITE}
  • hopefully encourages people to write tests for their PHP_CodeSniffer sniffs!

Differences between this class and the one included with PHP_CodeSniffer:

  • The runTests() method is public and marked as a PHPUnit test (ie: @test). It also runs per sniff automatically, as in only one sniff will be tested with it's corresponding .inc file. Makes sense, right?
  • TEST_PATH (required)
    • Because this package is installable via composer it's conceptually better to define somewhere, somehow, where your tests are located. Also, it's a bit less nebulous.
  • STANDARD_PATH (optional)
    • This is specifically for standards that you have not yet officially installed in your instance of phpcs. If this const is not defined, the class will use the original method - parse the test class name & assume that everything is in the phpcs home dir
  • TEST_EXT (optional)
    • The original suite required all your tests to be {$SNIFF_NAME}UnitTest.php. Setting this constant allows you to override the UnitTest portion completely, giving you some flexibility when organizing your tests.

All of these constants can just be defined in a bootstrap script that requires the composer bootstrap. eg:

<?php
require_once( __DIR__ . '/../vendor/autoload.php' );
define( 'TEST_PATH', __DIR__ . '/Awesomeness' );
define( 'STANDARD_PATH', __DIR__ . '/../Awesomeness' );
define( 'TEST_EXT', 'SniffTest.php' );

And, depending on how you run your tests, require this bootstrap script in either your Suite script or phpunit.xml.dist

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Unknown
  • 更新时间: 2014-10-27

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固