FAQ
Edit report at https://pear.php.net/bugs/bug.php?id=18651&edit=1

ID: 18651
Comment by: aoudin@parkeon.com
Reported By: gaurav dot deshmukh123@gmail.com
Summary: PHPunit Test cases for custom standards are not
working on Windows.
Status: Open
Type: Bug
Package: PHP_CodeSniffer
Operating System: Windows/Linux
Package Version: 1.3.0
PHP Version: 5.3.6
Roadmap Versions:
New Comment:

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


Previous Comments:
------------------------------------------------------------------------

[2012-06-12 16:01:32] aoudin

Added #patch
bug:18651;patch:patch_fix_path_bug_windows;revision:1339513292;.

------------------------------------------------------------------------

[2011-07-05 13:59:42] ggaurav123

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?

------------------------------------------------------------------------

[2011-07-05 13:58:48] ggaurav123

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?

------------------------------------------------------------------------

Search Discussions

  • Gsherwood at Jun 18, 2012 at 6:33 am
    Edit report at https://pear.php.net/bugs/bug.php?id=18651&edit=1

    ID: 18651
    Updated by: gsherwood@squiz.net
    Reported By: gaurav dot deshmukh123@gmail.com
    Summary: PHPunit Test cases for custom standards are not
    working on Windows.
    -Status: Open
    +Status: Feedback
    Type: Bug
    Package: PHP_CodeSniffer
    Operating System: Windows/Linux
    Package Version: 1.3.0
    PHP Version: 5.3.6
    -Assigned To:
    +Assigned To: squiz
    Roadmap Versions:
    New Comment:

    -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


    Previous Comments:
    ------------------------------------------------------------------------

    [2012-06-12 16:05:22] aoudin

    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-12 16:01:32] aoudin

    Added #patch
    bug:18651;patch:patch_fix_path_bug_windows;revision:1339513292;.

    ------------------------------------------------------------------------

    [2011-07-05 13:59:42] ggaurav123

    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?

    ------------------------------------------------------------------------

    [2011-07-05 13:58:48] ggaurav123

    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?

    ------------------------------------------------------------------------

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppear-bugs @
categoriesphp
postedJun 12, '12 at 2:00p
activeJun 18, '12 at 6:33a
posts2
users2
websitepear.php.net

2 users in discussion

Aoudin: 1 post Gsherwood: 1 post

People

Translate

site design / logo © 2022 Grokbase