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

Allow to enable/disable pretty print via CLI #1

Closed
robiningelbrecht opened this issue Aug 20, 2023 · 8 comments · Fixed by #2
Closed

Allow to enable/disable pretty print via CLI #1

robiningelbrecht opened this issue Aug 20, 2023 · 8 comments · Fixed by #2
Assignees
Labels
enhancement New feature or request

Comments

@robiningelbrecht
Copy link
Owner

robiningelbrecht commented Aug 20, 2023

Currently when adding the extension in the PHPUnit XML file, the output is always prettified. It should be possible to enable/disable this with an argument in the CLI command

Requested by @TomasVotruba in indentno/phpunit-pretty-print#47

@TomasVotruba suggestion on how you would approach this?

@robiningelbrecht robiningelbrecht self-assigned this Aug 20, 2023
@robiningelbrecht robiningelbrecht added the enhancement New feature or request label Aug 20, 2023
@TomasVotruba
Copy link

TomasVotruba commented Aug 20, 2023

Hi,

thanks for creating the isuse :) 👍

I don't use PHPUnit internals much, so not sure this is possible.

In PHPUnit 9 there was a "printer" option: https://github.com/indentno/phpunit-pretty-print

vendor/bin/phpunit --printer 'Sempro\PHPUnitPrettyPrinter\PrettyPrinter' tests/

But I can't find it in PHPUnit 10 options:

vendor/bin/phpunit -h | grep "printer"
>

@robiningelbrecht
Copy link
Owner Author

robiningelbrecht commented Aug 20, 2023

@TomasVotruba there's indeed no printer option in PHPUnit 10 anymore, everything is managed through extensions. What I'd suggest to do is something like this:

<extensions>
    <bootstrap class="RobinIngelbrecht\PHPUnitPrettyPrint\PhpUnitExtension">
        <parameter name="enabled" value="true|false"/>
    </bootstrap>
</extensions>

or at runtime

> vendor/bin/phpunit -d --enable-pretty-print

The default value of this new option would always be "true". Your use case could then be solved by setting your XML to

<extensions>
    <bootstrap class="RobinIngelbrecht\PHPUnitPrettyPrint\PhpUnitExtension">
        <parameter name="enabled" value="false"/>
    </bootstrap>
</extensions>

and run

> vendor/bin/phpunit -d --enable-pretty-print

What do you think?

@TomasVotruba
Copy link

That seems great, I'd love to use this 👍

Does this work already?

@robiningelbrecht
Copy link
Owner Author

@TomasVotruba no, something I need to implement still. I'll try to finish this this week. Maybe tomorrow :)

@TomasVotruba
Copy link

@robiningelbrecht Awesome, thank you for helpling out 👍

@robiningelbrecht
Copy link
Owner Author

robiningelbrecht commented Aug 21, 2023

@TomasVotruba, see #2, what do you think?

@robiningelbrecht robiningelbrecht linked a pull request Aug 21, 2023 that will close this issue
@robiningelbrecht
Copy link
Owner Author

@TomasVotruba released a new version 1.2.2

@TomasVotruba
Copy link

Thank you 👏

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

Successfully merging a pull request may close this issue.

2 participants