Edit report at https://pear.php.net/bugs/bug.php?id=19976&edit=1
ID: 19976
Updated by: [email protected]
Reported By: cweiske at php dot net
Summary: Run own CS tests without being installed
-Status: Assigned
+Status: Closed
Type: Feature/Change Request
Package: PHP_CodeSniffer
Package Version: 1.5.0RC2
PHP Version: Irrelevant
Assigned To: squiz
Roadmap Versions:
New Comment:
-Status: Assigned
+Status: Closed
This has now been solved by this commit:
https://github.com/squizlabs/PHP_CodeSniffer/commit/f373d1b5e08db0fcc4cc6e0c962
76a93b4f60768
If you have standards outside the install dir, tell PHPCS about them
using the
installed_paths config var. PHPCS will then treat them as installed
standards for both
normal runs and (after this commit) for unit tests runs as well.
More discussion and examples can be found here:
https://github.com/WordPress-
Coding-Standards/WordPress-Coding-Standards/pull/198#event-139056569
Previous Comments:
------------------------------------------------------------------------
[2013-08-01 07:41:46] squiz
-Status: Feedback
+Status: Open
------------------------------------------------------------------------
[2013-07-12 17:20:35] cweiske
Source tree:
.
??? PHP
? ??? CodeSniffer
? ??? Standards
? ??? Netresearch
? ? ??? ruleset.xml
? ? ??? Sniffs
? ? ??? Files
? ? ? ??? DeclareEncodingSniff.php
?? tests
??? bootstrap.php
??? NRT3AbstractSniffUnitTest.php
??? PHP
? ??? CodeSniffer
? ??? Standards
? ??? NRT3
? ??? Sniffs
? ??? Files
? ? ??? OneClassPerFileSniffUnitTest.inc
??? phpunit.xml
Now the question is how to run the tests for the sniffs when the coding
standard is not installed, but PHP_CodeSniffer is installed via PEAR.
I wanted to use AbstractSniffUnitTest.php as base class for my phpunit
test classes, but that class expects the sniff class files in
/usr/share/pear/... because PHP_CodeSniffer is installed there.
------------------------------------------------------------------------
[2013-06-18 06:11:40] squiz
-Status: Open
+Status: Feedback
-Assigned To:
+Assigned To: squiz
Hi Christian, can you give me a bit more info about how you are trying
to run the
tests and what the structure of your code is?
Do you just have your own directory structure, like:
MyStandard/
Sniffs/
...
Tests/
...
ruleset.xml
And how are you trying to run the tests? Do you have your own test
suite, or are
you more referring to the fact that there isn't a command you can really
use to run
them?
------------------------------------------------------------------------
[2013-06-12 10:50:00] cweiske
Description:
------------
It is currently not possible to run unit tests for an own ruleset that
has not been installed via PEAR.
This is because AbstractSniffUnitTest.php detects if PHP_CodeSniffer is
installed, and then assumes that the tests to execute are also in the
same path as PHP_CodeSniffer itself.
Now I'd like to run the tests of my not installed ruleset with an
installed version of php_codesniffer :)
------------------------------------------------------------------------
--
Edit this bug report at https://pear.php.net/bugs/bug.php?id=19976&edit=1
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.