Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No documented way to use only the PHPUnit (10) printer #297

Open
Bilge opened this issue Dec 1, 2023 · 9 comments
Open

No documented way to use only the PHPUnit (10) printer #297

Bilge opened this issue Dec 1, 2023 · 9 comments

Comments

@Bilge
Copy link

Bilge commented Dec 1, 2023

If one wishes to only use the PHPUnit 10 printer, it is unclear how to do this, since there is no extension to bootstrap.

@robiningelbrecht
Copy link

robiningelbrecht commented Dec 14, 2023

@Bilge You can use this extension that uses Collision: https://github.com/robiningelbrecht/phpunit-pretty-print

@Bilge
Copy link
Author

Bilge commented Dec 14, 2023

OK, but that seems like it does a lot more than just enable Collision, what with the Chuck Norris quotes and other unnecessary guff.

In reality, isn't this the single and only line that is actually needed to enable the printer?

https://github.com/robiningelbrecht/phpunit-pretty-print/blob/5d42dbf9d92a6299d3307d59b1a67c9eba22e065/src/PhpUnitExtension.php#L35

@robiningelbrecht
Copy link

robiningelbrecht commented Dec 15, 2023

@Bilge Everything is disabled by default.
And yes that line is the bare minimum you need to run Collision, but I think you need to run it in an PHPUnit extension to make it work.

@Bilge
Copy link
Author

Bilge commented Dec 15, 2023

I imagine you could just run it in the bootstrap file, no?

@robiningelbrecht
Copy link

robiningelbrecht commented Dec 15, 2023

@Bilge That might an option as well indeed, never tried this before.
Since PHPUnit 10 I tend to work with the "extensions and events" it provides...

@Bilge
Copy link
Author

Bilge commented Dec 15, 2023

It seems this is wrong. There appears to be some autoload trick going on that causes EnsurePrinterIsRegisteredSubscriber::register(); to be called automatically (see Autoload.php). Therefore, the only thing required to enable the printer is to ensure COLLISION_PRINTER environment variable is set (to anything, including nothing).

However, when I do this, although the printer is enabled, the output is messed up as it is now a mish-mash of Collision and PHPUnit output (it outputs the dots (...) between tests). Moreover, the text colour is dark grey which is difficult to read; I don't know if this is intended or not, but it wasn't the case with v6.

image

If I use your extension, the dots go away, but the text is still illegible. Presumably the dots are fixed by instructing PHPUnit to omit its own test output as here: https://github.com/robiningelbrecht/phpunit-pretty-print/blob/5d42dbf9d92a6299d3307d59b1a67c9eba22e065/src/PhpUnitExtension.php#L24C18-L24C39 What is strange about this is that there does not appear to be any equivalent call in Collision itself. But how do we even know Collision v7 even works with PHPUnit, considering its own test suite does not appear to activate the printer at all?


Aside, the text colour in v6 was also grey, but a lot lighter.

image

@robiningelbrecht
Copy link

@Bilge yeah indeed, you need to disable PHPUnit10's output, forgot about that, sorry.

But how do we even know Collision v7 even works with PHPUnit

Because the extension you are referring to has it's own test suite and proves it works?

@srtfisher
Copy link

Previously non-Laravel projects had the option to use printerClass and enjoy collision. Now it seems that those outside of Laravel (or those who run vendor/bin/phpunit directly rather than through a wrapper function) can't use collision as easily.

@Bilge
Copy link
Author

Bilge commented Apr 22, 2024

Yeah but why wouldn't everyone be using Laravel, the best static framework where everything is static and what even is concurrency safety anyway?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants