squizlabs / PHP_CodeSniffer

PHP_CodeSniffer tokenizes PHP files and detects violations of a defined set of coding standards.
BSD 3-Clause "New" or "Revised" License
10.63k stars 1.48k forks source link

Error executing phpunit. #3909

Closed nelson1995 closed 8 months ago

nelson1995 commented 8 months ago

PHP_CodeSniffer Bug

I want to contribute to PHP_Codesniffer and I followed the CONTRIBUTING.md documentation and executed them. After executing phpunit I encountered this error. Screenshot from 2023-10-28 20-39-58

To reproduce

This is the steps I took to reproduce the behavior:

  1. Ran cd PHP_CodeSniffer
  2. Ran bin/phpcs
  3. Ran phpunit

This was the output after executing script bin/phpcs Screenshot from 2023-10-28 21-22-44

My environment details

Operating System Ubuntu 22.04.2 LTS
PHP version 8.2.8
PHP_CodeSniffer version 3.5.5, master
Standard [e.g., PSR2, PSR12, Squiz, custom]
Install type git clone
PHPUnit version 9.5.10

Please confirm:

jrfnl commented 8 months ago

@nelson1995 Thank you for your interest in contributing to PHPCS.

This is not a bug, but a question though, so please don't open a bug report for something like this.

Now, as for running the unit tests, there are a couple of issues here:

  1. You are trying to run the tests with an incompatible PHPUnit version. The tests are currently only compatible with PHPUnit 4 - 7, not with PHPUnit 9. There is a PR open to change this.
  2. You are trying to run the tests on PHP 8.2. While this is possible with PHPUnit 7, the config file will not parse, so you would need to pass the config via the command line.

To get up and running quickly, I'd suggest running composer install and then using vendor/bin/phpunit on PHP 7.4.

If you want more extensive information, I suggest you have a read through the open PR which updates the CONTRIBUTING.md file.

nelson1995 commented 8 months ago

@jrfnl my apologies for the error. Thank you for the feedback. I’m going to resolve it.

nelson1995 commented 8 months ago

Hello Juliette,

A quick question. Why does PHPUnit return an error “class Php_Timer not found” ? I’m running PHPUnit via ./vendor/bin/phpunit with PHP version 7.4 and I checked the installed PHPUnit version has “Php_Timer” class.

Regards, Nelson Katale

On Sat, 28 Oct 2023 at 21:48, Juliette @.***> wrote:

@nelson1995 https://github.com/nelson1995 Thank you for your interest in contributing to PHPCS.

This is not a bug, but a question though, so please don't open a bug report for something like this.

Now, as for running the unit tests, there are a couple of issues here:

  1. You are trying to run the tests with an incompatible PHPUnit version. The tests are currently only compatible with PHPUnit 4 - 7, not with PHPUnit 9. There is a PR open to change this https://github.com/squizlabs/PHP_CodeSniffer/pull/3803.
  2. You are trying to run the tests on PHP 8.2. While this is possible with PHPUnit 7, the config file will not parse, so you would need to pass the config via the command line.

To get up and running quickly, I'd suggest running composer install and then using vendor/bin/phpunit on PHP 7.4.

If you want more extensive information, I suggest you have a read through the open PR which updates the CONTRIBUTING.md file https://github.com/squizlabs/PHP_CodeSniffer/pull/3830/files.

— Reply to this email directly, view it on GitHub https://github.com/squizlabs/PHP_CodeSniffer/issues/3909#issuecomment-1783895947, or unsubscribe https://github.com/notifications/unsubscribe-auth/AECUIUSO6KP4KH4ZT3ECRBTYBVHPPAVCNFSM6AAAAAA6UIB2CSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTOOBTHA4TKOJUG4 . You are receiving this because you were mentioned.Message ID: @.***>

jrfnl commented 8 months ago

@nelson1995 I honestly don't know. Try running composer du to make sure the autoload file is up to date.

nelson1995 commented 8 months ago

I ran the “composer du” command and everything is updated. Unfortunately the error still persists.

On Sat, 11 Nov 2023 at 20:53, Juliette @.***> wrote:

@nelson1995 https://github.com/nelson1995 I honestly don't know. Try running composer du to make sure the autoload file is up to date.

— Reply to this email directly, view it on GitHub https://github.com/squizlabs/PHP_CodeSniffer/issues/3909#issuecomment-1806877623, or unsubscribe https://github.com/notifications/unsubscribe-auth/AECUIUT77KADOLOIBMYX4DTYD63RVAVCNFSM6AAAAAA6UIB2CSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMBWHA3TONRSGM . You are receiving this because you were mentioned.Message ID: @.***>

jrfnl commented 8 months ago

@nelson1995 Well, as I don't see the error, there's not much I can do to help you without you providing more information....