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

Make phpunit (or Brain Monkey) a dependency #662

Open
GaryJones opened this issue Nov 13, 2017 · 1 comment
Open

Make phpunit (or Brain Monkey) a dependency #662

GaryJones opened this issue Nov 13, 2017 · 1 comment

Comments

@GaryJones
Copy link
Contributor

GaryJones commented Nov 13, 2017

One of the good practices of software development is that dependencies are explicit and isolated.

This project contains some unit / integration tests, but phpunit is not listed in require-dev in composer.json. That means it's assuming that developers have it installed, but that means it's then making assumptions about which version is installed, and therefore what features can be used / not used in tests.

Note: The Travis config file actually already includes different versions of PHPUnit depending on which version of PHP is available.


Before just including phpunit as a require-dev dependency though, I want to put forward an extension of this idea:

A quick scan of the tests suggest that at least some of them are unit tests - that is, testing one function or method, without the need to bootstrap WP first. Even some of the other tests could easily have certain WP functions mocked, without needing to be full integration tests involving a database.

My preference, and suggestion, would be to use Brain Monkey, which includes phpunit as a dependency, but already has support for testing actions and filters, and monkey-patches PHP / WP functions.

This then allows there to be a distinction between unit tests (quick, standalone tests), and integration (requires WP to be bootstrapped), which can make running test suites much quicker. An example of the tests/ layout can be seen here, and you can see that the bootstrap.php only conditionally loads WP depending on which --testsuite is run.

@tw2113
Copy link
Member

tw2113 commented Nov 13, 2017

Color me interested :D

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

No branches or pull requests

2 participants