mikeerickson / phpunit-pretty-result-printer

PHPUnit Pretty Result Printer -- make your PHPUnit tests look pretty!
MIT License
1.2k stars 71 forks source link

Could not use "Codedungeon\\PHPUnitPrettyResultPrinter\\Printer" as printer: class does not exist #13

Closed okaufmann closed 6 years ago

okaufmann commented 6 years ago

Hi,

I tried to use the Printer on windows with phpunit 6.5.5 in a Laravel Project.

When I add it to phpunit.xml and run the tests they appear to run forever with no output. When I set the printer in commandline I get the following error:

$ phpunit --printer=Codedungeon\\PHPUnitPrettyResultPrinter\\Printer
PHPUnit 6.5.5 by Sebastian Bergmann and contributors.

Could not use "Codedungeon\\PHPUnitPrettyResultPrinter\\Printer" as printer: class does not exist

Is this a Windows related issue or am a doing something wrong?

Thanks

guruas3 commented 6 years ago

I have the same issue on Windows.

The problem is in this block of code: code as it never closes the while loop. Because this condition : code is never satisfied on Windows. As $configPath changes in the while loop and goes 1 directory up at a time it reaches this value C:\ and then goes into infinite loop.

I'm not sure about the ideal solution but i've temporarily done this for myself locally: $configPath === "/" || (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') && $configPath === 'C:\\'

P.S. the tests written for Printer class also going into infinite loop.

mikeerickson commented 6 years ago

Hey guys, I am on vacation until Tuesday. I will have a look at this when I return.

mfour-merickson commented 6 years ago

@okaufmann @guruas3 Hey guys, just getting back to these issues. Can you please share with me what version of Windows you are using.

guruas3 commented 6 years ago

I have Windows 7. But i don't think it's relevant as all versions of Windows should have the same error. I showed you why in my previous comment. $configPath will be equal to / just in linux systems, and in windows it will be in the different format C:\

mikeerickson commented 6 years ago

I am going to be testing with Windows 10 and will update accordingly. Just wanted to make sure to cover all the possible basis

On Jan 2, 2018, at 11:31 AM, guruas3 notifications@github.com wrote:

I have Windows 7. But i don't think it's relevant as all versions of Windows should have the same error. I showed you why in my previous comment. $configPathwill be equal to / just in linux systems, and in windows it will be in the different format C:\

mikeerickson commented 6 years ago

@guruas3 On the surface, it looks like you adjustments will be satisfactory, but will do some more thorough testing to make sure.

guruas3 commented 6 years ago

@mikeerickson Yeah sure. The problem with my fix is that it depends on the disk where the project is located. So let's suppose i have a project in D:\MyProjects\etc the $configPath will become D:\ and not C:\. The only thing that comes to my mind is refactor the while loop.

mikeerickson commented 6 years ago

I have a solution for this issue, just need to do more testing and adding some other changes planed for next version.

okaufmann commented 6 years ago

I'm using it on Windows 10

EmanueleCoppola commented 6 years ago

@mikeerickson any news on this?

Qussayyon commented 6 years ago

@mikeerickson I'm using PHP 7.2, on Ubuntu 18.04. Still giving me error: Could not use "Codedungeon\PHPUnitPrettyResultPrinter\Printer" as printer

peterlupu commented 6 years ago

for those on windows, see #39

mikeerickson commented 6 years ago

As commented on #39 I will be merging and tagging this afternoon.

mikeerickson commented 6 years ago

Fixed with #39