maglnet / ComposerRequireChecker

A CLI tool to check whether a specific composer package uses imported symbols that aren't part of its direct composer dependencies
MIT License
872 stars 70 forks source link

Add tests for Phar file #515

Closed fredden closed 4 months ago

fredden commented 4 months ago

I would like to add some tests to verify the behaviour of the phar file as part of #511. However, given that the phar file seems to be currently untested, I'm adding a basic set of tests here as there are multiple approaches for this, and I don't want to pollute #511 with that discussion.

In this pull request, I'm using phing to build the phar in a setUpBeforeClass() method, but because that library messes with the composer installation, I'm wrapping that with composer install.

Another approach would be to use phing to build the phar in a GitHub Action workflow (eg, based on .github/workflows/phar-creation.yml), and then run some stand-alone tests written in a shell script or similar. This approach would remove the complication of having to compile a phar / use phing from within phpunit, but would mean we'd have to maintain two different testing frameworks.

In this pull request, I've chosen to skip the tests for the phar file if it's not found on disk, and to build the phar as part of the GitHub Actions workflow, just before we run the phpunit test suite.

fredden commented 4 months ago

@maglnet I think this one's ready for review. Feel free to squash-merge this via GitHub, or let me know if you'd like me to rebase this so there are fewer commits here.