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

  ID: 20053
  Updated by: gsherwood@squiz.net
  Reported By: ffrey dot web@gmail.com
  Summary: phpunit tests fail with phpunit 3.7 (phar)
  Status: Feedback
  Type: Documentation Problem
  Package: PHP_CodeSniffer
  Operating System: windows 8
  Package Version: 1.5.0RC3
  PHP Version: 5.3.27
  Assigned To: squiz
  Roadmap Versions:
  New Comment:

Ah ok, that makes sense now. Yes, the PEAR installer downloads the files
and puts
them in a central location.

I'll see what I can do about those requires to make it work with both
methods.


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

[2013-08-26 10:44:27] ffrey

-Summary: phpunit tests fail with phpunit 3.7
+Summary: phpunit tests fail with phpunit 3.7 (phar)
I use the "phar archive" of phpunit (presented as "easiest way" to
install
http://phpunit.de/manual/current/en/installation.html).

All classes are included within the phar, hence the collusion with the
requires &
includes within the test, i presume.

I suppose the pear install downloads phpunit files as separate files ?

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

[2013-08-26 05:34:28] squiz

-Status: Open
+Status: Feedback
-Assigned To:
+Assigned To: squiz
I don't think this has anything to do with the PHPUnit version. Your
version works
fine for me:

72:tests gsherwood$ phpunit PHP_CodeSniffer/AllTests.php

PHPUnit 3.7.24 by Sebastian Bergmann.

............................................................... 63 /
211 ( 29%)
............................................................... 126 /
211 ( 59%)
...........................SS.................................. 189 /
211 ( 89%)
......................

Time: 2.8 seconds, Memory: 45.00Mb

OK, but incomplete or skipped tests!
Tests: 211, Assertions: 54, Skipped: 2.

So I'd need to find out what is different about your install. I have
PHPUnit installed
via PEAR, so all the require_once statements should end up trying to
require the
PEAR installed code. In this case, PHP would obviously only include the
file one, and
so you wont get a duplicate class name. In your case, the require_once
call must
be pointing to a different install.

Do you have phpunit installed in multiple locations or by multiple
methods? Is your
php include_path set correctly for the one you want to use? I'm not sure
what else
might be wrong.

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

[2013-08-23 13:05:46] ffrey

Description:
------------
Unit testing with phpunit 3.7 fails.
This is due to the presence of "^require_once 'PHPUnit.+" in 19
files of the test suite.
Deletion of those requires solves the problem.

Test script:
---------------
phpunit
C:\Users\...\php_libs\pear\tests\PHP_CodeSniffer.1-5\AllTests.php

Expected result:
----------------
PHPUnit 3.7.24 by Sebastian Bergmann.

.................

Time: 1.83 seconds, Memory: 6.00Mb

OK (17 tests, 54 assertions)

Actual result:
--------------
Fatal error: Cannot redeclare class PHPUnit_TextUI_TestRunner

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

Search Discussions

  • Gsherwood at Aug 27, 2013 at 3:31 am
    Edit report at https://pear.php.net/bugs/bug.php?id=20053&edit=1

      ID: 20053
      Updated by: gsherwood@squiz.net
      Reported By: ffrey dot web@gmail.com
      Summary: phpunit tests fail with phpunit 3.7 (phar)
    -Status: Feedback
    +Status: Closed
      Type: Documentation Problem
      Package: PHP_CodeSniffer
      Operating System: windows 8
      Package Version: 1.5.0RC3
      PHP Version: 5.3.27
      Assigned To: squiz
      Roadmap Versions:
      New Comment:

    -Status: Feedback
    +Status: Closed
    Was easy in the end. Just needed to wrap a couple of requires in
    class_exists() calls
    and could remove the rest. Commit is here:
    https://github.com/squizlabs/PHP_CodeSniffer/commit/ad5ff17366a9f6d2cdd81feebcfd
    49a6de7a8fbc

    Thanks for the report.


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

    [2013-08-27 05:22:53] squiz

    Ah ok, that makes sense now. Yes, the PEAR installer downloads the files
    and puts
    them in a central location.

    I'll see what I can do about those requires to make it work with both
    methods.

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

    [2013-08-26 10:44:27] ffrey

    -Summary: phpunit tests fail with phpunit 3.7
    +Summary: phpunit tests fail with phpunit 3.7 (phar)
    I use the "phar archive" of phpunit (presented as "easiest way" to
    install
    http://phpunit.de/manual/current/en/installation.html).

    All classes are included within the phar, hence the collusion with the
    requires &
    includes within the test, i presume.

    I suppose the pear install downloads phpunit files as separate files ?

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

    [2013-08-26 05:34:28] squiz

    -Status: Open
    +Status: Feedback
    -Assigned To:
    +Assigned To: squiz
    I don't think this has anything to do with the PHPUnit version. Your
    version works
    fine for me:

    72:tests gsherwood$ phpunit PHP_CodeSniffer/AllTests.php

    PHPUnit 3.7.24 by Sebastian Bergmann.

    ............................................................... 63 /
    211 ( 29%)
    ............................................................... 126 /
    211 ( 59%)
    ...........................SS.................................. 189 /
    211 ( 89%)
    ......................

    Time: 2.8 seconds, Memory: 45.00Mb

    OK, but incomplete or skipped tests!
    Tests: 211, Assertions: 54, Skipped: 2.

    So I'd need to find out what is different about your install. I have
    PHPUnit installed
    via PEAR, so all the require_once statements should end up trying to
    require the
    PEAR installed code. In this case, PHP would obviously only include the
    file one, and
    so you wont get a duplicate class name. In your case, the require_once
    call must
    be pointing to a different install.

    Do you have phpunit installed in multiple locations or by multiple
    methods? Is your
    php include_path set correctly for the one you want to use? I'm not sure
    what else
    might be wrong.

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

    [2013-08-23 13:05:46] ffrey

    Description:
    ------------
    Unit testing with phpunit 3.7 fails.
    This is due to the presence of "^require_once 'PHPUnit.+" in 19
    files of the test suite.
    Deletion of those requires solves the problem.

    Test script:
    ---------------
    phpunit
    C:\Users\...\php_libs\pear\tests\PHP_CodeSniffer.1-5\AllTests.php

    Expected result:
    ----------------
    PHPUnit 3.7.24 by Sebastian Bergmann.

    .................

    Time: 1.83 seconds, Memory: 6.00Mb

    OK (17 tests, 54 assertions)

    Actual result:
    --------------
    Fatal error: Cannot redeclare class PHPUnit_TextUI_TestRunner

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

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppear-bugs @
categoriesphp
postedAug 27, '13 at 3:17a
activeAug 27, '13 at 3:31a
posts2
users1
websitepear.php.net

1 user in discussion

Gsherwood: 2 posts

People

Translate

site design / logo © 2022 Grokbase