Skip to content

Commit d89c165

Browse files
committed
Changelog + PEAR support for squizlabs#1384
1 parent 788c46a commit d89c165

File tree

3 files changed

+46
-43
lines changed

3 files changed

+46
-43
lines changed

package.xml

+17-3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,15 @@ http://pear.php.net/dtd/package-2.0.xsd">
2626
</stability>
2727
<license uri="https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt">BSD 3-Clause License</license>
2828
<notes>
29+
- This release includes a change to support newer versions of PHPUnit (versions 4, 5, and 6 are now supported)
30+
-- The custom PHP_CodeSniffer test runner now requires a bootstrap file
31+
-- Developers with custom standards using the PHP_CodeSniffer test runner will need to do one of the following:
32+
--- run your unit tests from the PHP_CodeSniffer root dir so the bootstrap file is included
33+
--- specify the PHP_CodeSniffer bootstrap file on the command line: phpunit --bootstrap=/path/to/phpcs/tests/bootstrap.php
34+
--- require the PHP_CodeSniffer bootstrap file from your own bootstrap file
35+
-- If you don't run PHP_CodeSniffer unit tests, this change will not affect you
36+
-- Thanks to Juliette Reinders Folmer for the patch
37+
2938
- A phpcs.xml or phpcs.xml.dist file now takes precedence over the default_standard config setting
3039
-- Thanks to Björn Fischer for the patch
3140
- Both phpcs.xml and phpcs.xml.dist files can now be prefixed with a dot (request #1566)
@@ -98,6 +107,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
98107
<file baseinstalldir="PHP/CodeSniffer" name="README.md" role="doc" />
99108
<file baseinstalldir="PHP/CodeSniffer" name="CONTRIBUTING.md" role="doc" />
100109
<file baseinstalldir="PHP/CodeSniffer" name="licence.txt" role="doc" />
110+
<file baseinstalldir="PHP/CodeSniffer" name="phpunit.xml.dist" role="test" />
101111
<dir name="bin">
102112
<file baseinstalldir="" name="phpcbf" role="script">
103113
<tasks:replace from="/usr/bin/env php" to="php_bin" type="pear-config" />
@@ -132,8 +142,8 @@ http://pear.php.net/dtd/package-2.0.xsd">
132142
<file baseinstalldir="" name="AbstractSniffUnitTest.php" role="test" />
133143
<file baseinstalldir="" name="AllSniffs.php" role="test" />
134144
</dir>
135-
<file baseinstalldir="" name="bootstrap.php" role="test" />
136145
<file baseinstalldir="" name="AllTests.php" role="test" />
146+
<file baseinstalldir="" name="bootstrap.php" role="test" />
137147
<file baseinstalldir="" name="TestSuite.php" role="test" />
138148
</dir>
139149
<dir name="src">
@@ -1569,8 +1579,10 @@ http://pear.php.net/dtd/package-2.0.xsd">
15691579
<install as="README" name="README.md" />
15701580
<install as="CONTRIBUTING" name="CONTRIBUTING.md" />
15711581
<install as="LICENCE" name="licence.txt" />
1582+
<install as="phpunit.xml" name="phpunit.xml.dist" />
15721583
<install as="AllTests.php" name="tests/AllTests.php" />
15731584
<install as="TestSuite.php" name="tests/TestSuite.php" />
1585+
<install as="tests/bootstrap.php" name="tests/bootstrap.php" />
15741586
<install as="CodeSniffer/Core/AllTests.php" name="tests/Core/AllTests.php" />
15751587
<install as="CodeSniffer/Core/IsCamelCapsTest.php" name="tests/Core/IsCamelCapsTest.php" />
15761588
<install as="CodeSniffer/Core/ErrorSuppressionTest.php" name="tests/Core/ErrorSuppressionTest.php" />
@@ -1591,8 +1603,10 @@ http://pear.php.net/dtd/package-2.0.xsd">
15911603
<install as="README" name="README.md" />
15921604
<install as="CONTRIBUTING" name="CONTRIBUTING.md" />
15931605
<install as="LICENCE" name="licence.txt" />
1594-
<install as="AllTests.php" name="tests/AllTests.php" />
1595-
<install as="TestSuite.php" name="tests/TestSuite.php" />
1606+
<install as="phpunit.xml" name="phpunit.xml.dist" />
1607+
<install as="tests/AllTests.php" name="tests/AllTests.php" />
1608+
<install as="tests/bootstrap.php" name="tests/bootstrap.php" />
1609+
<install as="tests/TestSuite.php" name="tests/TestSuite.php" />
15961610
<install as="CodeSniffer/Core/AllTests.php" name="tests/Core/AllTests.php" />
15971611
<install as="CodeSniffer/Core/IsCamelCapsTest.php" name="tests/Core/IsCamelCapsTest.php" />
15981612
<install as="CodeSniffer/Core/ErrorSuppressionTest.php" name="tests/Core/ErrorSuppressionTest.php" />

phpunit.xml.dist

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit backupGlobals="true" bootstrap="tests/bootstrap.php">
2+
<phpunit backupGlobals="true" beStrictAboutTestsThatDoNotTestAnything="false" bootstrap="tests/bootstrap.php">
33
<testsuites>
44
<testsuite name="PHP_CodeSniffer Test Suite">
55
<file>tests/AllTests.php</file>

tests/Standards/AllSniffs.php

+28-39
Original file line numberDiff line numberDiff line change
@@ -58,59 +58,48 @@ public static function suite()
5858

5959
$installedStandards = Standards::getInstalledStandardDetails(true);
6060

61-
foreach ($installedStandards as $name => $details) {
61+
foreach ($installedStandards as $standard => $details) {
6262
Autoload::addSearchPath($details['path'], $details['namespace']);
6363

64-
$standards = Standards::getInstalledStandards(true, $details['path']);
65-
6664
// If the test is running PEAR installed, the built-in standards
6765
// are split into different directories; one for the sniffs and
6866
// a different file system location for tests.
69-
if ($isInstalled === true && is_dir($details['path'].DIRECTORY_SEPARATOR.'Generic') === true) {
70-
$testPath = realpath(__DIR__.'/../../src/Standards');
67+
if ($isInstalled === true && is_dir(dirname($details['path']).DIRECTORY_SEPARATOR.'Generic') === true) {
68+
$testPath = realpath(__DIR__.'/../../src/Standards/'.$standard);
7169
} else {
7270
$testPath = $details['path'];
7371
}
7472

75-
foreach ($standards as $standard) {
76-
if (in_array($standard, $ignoreTestsForStandards) === true) {
73+
if (in_array($standard, $ignoreTestsForStandards) === true) {
74+
continue;
75+
}
76+
77+
$testsDir = $testPath.DIRECTORY_SEPARATOR.'Tests'.DIRECTORY_SEPARATOR;
78+
if (is_dir($testsDir) === false) {
79+
// No tests for this standard.
80+
continue;
81+
}
82+
83+
$di = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($testsDir));
84+
85+
foreach ($di as $file) {
86+
// Skip hidden files.
87+
if (substr($file->getFilename(), 0, 1) === '.') {
7788
continue;
7889
}
7990

80-
$standardDir = $details['path'].DIRECTORY_SEPARATOR.$standard;
81-
$testsDir = $testPath.DIRECTORY_SEPARATOR.$standard.DIRECTORY_SEPARATOR.'Tests'.DIRECTORY_SEPARATOR;
82-
83-
if (is_dir($testsDir) === false) {
84-
// Check if the installed path is actually a standard itself.
85-
$standardDir = $details['path'];
86-
$testsDir = $testPath.DIRECTORY_SEPARATOR.'Tests'.DIRECTORY_SEPARATOR;
87-
if (is_dir($testsDir) === false) {
88-
// No tests for this standard.
89-
continue;
90-
}
91+
// Tests must have the extension 'php'.
92+
$parts = explode('.', $file);
93+
$ext = array_pop($parts);
94+
if ($ext !== 'php') {
95+
continue;
9196
}
9297

93-
$di = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($testsDir));
94-
95-
foreach ($di as $file) {
96-
// Skip hidden files.
97-
if (substr($file->getFilename(), 0, 1) === '.') {
98-
continue;
99-
}
100-
101-
// Tests must have the extension 'php'.
102-
$parts = explode('.', $file);
103-
$ext = array_pop($parts);
104-
if ($ext !== 'php') {
105-
continue;
106-
}
107-
108-
$className = Autoload::loadFile($file->getPathname());
109-
$GLOBALS['PHP_CODESNIFFER_STANDARD_DIRS'][$className] = $standardDir;
110-
$GLOBALS['PHP_CODESNIFFER_TEST_DIRS'][$className] = $testsDir;
111-
$suite->addTestSuite($className);
112-
}
113-
}//end foreach
98+
$className = Autoload::loadFile($file->getPathname());
99+
$GLOBALS['PHP_CODESNIFFER_STANDARD_DIRS'][$className] = $details['path'];
100+
$GLOBALS['PHP_CODESNIFFER_TEST_DIRS'][$className] = $testsDir;
101+
$suite->addTestSuite($className);
102+
}
114103
}//end foreach
115104

116105
return $suite;

0 commit comments

Comments
 (0)