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 PHPUnit Tests to Bootstrap Drupal #1048

Closed
mikemadison13 opened this issue Feb 7, 2017 · 4 comments
Closed

Allow PHPUnit Tests to Bootstrap Drupal #1048

mikemadison13 opened this issue Feb 7, 2017 · 4 comments
Labels
Enhancement A feature or feature request

Comments

@mikemadison13
Copy link
Contributor

mikemadison13 commented Feb 7, 2017

Currently PHPUnit doesn't include any references to Drupal (specifically, no bootstrap, and no reference to the Drupal config file at ${docroot}/core/phpunit.xml.dist).

It would be ideal if BLT had some method of allowing PHPUnit tests to include this parameter, as it is possible to have tests that are perfectly valid WITH this parameter that will FAIL without.

Note that I have attempted to modify the phing call https://github.com/acquia/blt/blob/8.x/phing/tasks/tests.xml#L243 per the parameters specific at https://www.phing.info/docs/guide/trunk/PHPUnitTask.html (see configuration) but it doesn't seem to actually load that configuration file.

<phpunit configuration="${docroot}/core/phpunit.xml.dist" printsummary="true" failureproperty="phpunit.failures" errorproperty="phpunit.errors">

Unclear if this is a bug in phing itself or something wrong with BLT. I have attempted this with the file renamed to just be .xml (no luck). I've also attempted to pass a bootstrap parameter (instead of the configuration parameter) and that also appears to be non-functional.

@mikemadison13
Copy link
Contributor Author

I have temporarily solved this issue by adding a custom phing target to my project, and executing the tests (in the module directory) with a custom exec script inside of the phpunit target.

<exec dir="${repo.root}" command="vendor/bin/phpunit docroot/modules/custom/<module>/tests -c docroot/core/phpunit.xml.dist" logoutput="true" checkreturn="true"/>

@mikemadison13
Copy link
Contributor Author

This ticket is related to, but not identical to #1047

@grasmash grasmash added the Enhancement A feature or feature request label Feb 7, 2017
@grasmash grasmash added the ready label Apr 7, 2017
@grasmash grasmash changed the title PHPUnit Bootstraps Drupal Allow PHPUnit Tests to Bootstrap Drupal Apr 7, 2017
@mikemadison13
Copy link
Contributor Author

Note that my work around for this no longer works (above) as the phing target for phpunit tests is no longer present in BLT 8.8.x

@grasmash
Copy link
Contributor

Resolved by #1047

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

No branches or pull requests

2 participants