Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 3.4.2

Bug #18651 PHPunit Test cases for custom standards are not working on Windows.
Submitted: 2011-07-05 17:58 UTC
From: ggaurav123 Assigned: squiz
Status: Closed Package: PHP_CodeSniffer (version 1.3.0)
PHP Version: 5.3.6 OS: Windows/Linux
Roadmaps: (Not assigned)    
Subscription  


 [2011-07-05 17:58 UTC] ggaurav123 (Gaurav Deshmukh)
Description: ------------ I have created Unit testcases for my custom standard rules.I have followed the all the instruction given in codesniffer test class library.Also I have taken refernce from folowing sites. http://no-mercy.h1236134.stratoserver.net/trac/libIwParsers/browser/trunk/3rdParty/PHP_CodeSniffer-1.2.0/CodeSniffer/Standards/PEAR/Tests/ & http://blueparabola.com/blog/coding-standard-analysis-using-phpcodesniffer When I executed test cases on windows envoirment, it return balnk result set as follows. C:\Program Files\PHP>phpunit PEAR\PHP\tests\AllTests.php PHPUnit 3.5.14 by Sebastian Bergmann. ........................................ Time: 3 seconds, Memory: 12.25Mb OK (40 tests, 146 assertions) Warning: Deprecated PHPUnit features are being used 2 times! Use --verbose for more information. But when I executed same test cases on linux enviorment ,it returns expected result set. When I checked the AbstractSniffUnitTest file, I found that there is mapping from Test file to Sniff file. When file being mapped, the file path contains the mixing of forward & backward slashes on windows. because of that it fails at following condition foreach ($di as $file) { $path = $file->getPathname(); if (substr($path, 0, strlen($testFileBase)) === $testFileBase) { if ($path !== $testFileBase.'php') { $testFiles[] = $path; } } } Is there any way to resolve this issue on windows?

Comments

 [2011-07-05 17:59 UTC] ggaurav123 (Gaurav Deshmukh)
Description: ------------ I have created Unit testcases for my custom standard rules.I have followed the all the instruction given in codesniffer test class library.Also I have taken refernce from folowing sites. http://no-mercy.h1236134.stratoserver.net/trac/libIwParsers/browser/trunk/3rdParty/PHP_CodeSniffer-1.2.0/CodeSniffer/Standards/PEAR/Tests/ & http://blueparabola.com/blog/coding-standard-analysis-using-phpcodesniffer When I executed test cases on windows envoirment, it return blank result set as follows. C:\Program Files\PHP>phpunit PEAR\PHP\tests\AllTests.php PHPUnit 3.5.14 by Sebastian Bergmann. ........................................ Time: 3 seconds, Memory: 12.25Mb OK (40 tests, 146 assertions) Warning: Deprecated PHPUnit features are being used 2 times! Use --verbose for more information. But when I executed same test cases on linux enviorment ,it returns expected result set. When I checked the AbstractSniffUnitTest file, I found that there is mapping from Test file to Sniff file. When file being mapped, the file path contains the mixing of forward & backward slashes on windows. because of that it fails at following condition foreach ($di as $file) { $path = $file->getPathname(); if (substr($path, 0, strlen($testFileBase)) === $testFileBase) { if ($path !== $testFileBase.'php') { $testFiles[] = $path; } } } Is there any way to resolve this issue on windows?
 [2012-06-12 20:01 UTC] aoudin (Alexandre Oudin)
 [2012-06-12 20:05 UTC] aoudin (Alexandre Oudin)
I found a similar bug and the fix is quite simple, you have to edit patch the file CodeSniffer.php, this only occured on windows because of directory separator mixed with / and \ see Patches http://pear.php.net/bugs/bug.php?id=18651&edit=12&patch=patch_fix_path_bug_windows&revision=latest
 [2012-06-18 12:38 UTC] squiz (Greg Sherwood)
-Status: Open +Status: Feedback -Assigned To: +Assigned To: squiz
I've committed a fix to the git repo. Along with a few other changes made recently, the tests run ok for me on Windows now. Please try them out if you can. https://github.com/squizlabs/PHP_CodeSniffer/commit/97a8219d26fba9ee9b323d904 c47bff44223bd77
 [2012-07-10 06:28 UTC] squiz (Greg Sherwood)
-Status: Feedback +Status: Closed
Assuming they work. If not, please reopen.