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

Running PHPUnit #1555

jameswmcnab opened this issue Jul 27, 2019 · 1 comment


Copy link

commented Jul 27, 2019

Working on a PR and I want to run the tests, but I'm a bit confused as to how the development environment is configured.

I know the readme says not to run vendor/bin/phpunit and to download and run PHPUnit 6, but I'm a bit confused as to why?

I get the following error:

PHP Fatal error:  Cannot redeclare redirect() (previously declared in /Users/jameswmcnab/dev/jameswmcnab/BookStack/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php:658) in /Users/jameswmcnab/dev/jameswmcnab/BookStack/app/helpers.php on line 161
PHP Stack trace:
PHP   1. {main}() /Users/jameswmcnab/dev/jameswmcnab/BookStack/vendor/phpunit/phpunit/phpunit:0
PHP   2. PHPUnit\TextUI\Command::main() /Users/jameswmcnab/dev/jameswmcnab/BookStack/vendor/phpunit/phpunit/phpunit:53
PHP   3. PHPUnit\TextUI\Command->run() /Users/jameswmcnab/dev/jameswmcnab/BookStack/vendor/phpunit/phpunit/src/TextUI/Command.php:148
PHP   4. PHPUnit\TextUI\Command->handleArguments() /Users/jameswmcnab/dev/jameswmcnab/BookStack/vendor/phpunit/phpunit/src/TextUI/Command.php:159
PHP   5. PHPUnit\TextUI\Command->handleBootstrap() /Users/jameswmcnab/dev/jameswmcnab/BookStack/vendor/phpunit/phpunit/src/TextUI/Command.php:788
PHP   6. PHPUnit\Util\Fileloader::checkAndLoad() /Users/jameswmcnab/dev/jameswmcnab/BookStack/vendor/phpunit/phpunit/src/TextUI/Command.php:991
PHP   7. PHPUnit\Util\Fileloader::load() /Users/jameswmcnab/dev/jameswmcnab/BookStack/vendor/phpunit/phpunit/src/Util/Fileloader.php:48
PHP   8. include_once() /Users/jameswmcnab/dev/jameswmcnab/BookStack/vendor/phpunit/phpunit/src/Util/Fileloader.php:64

However just renaming that helper function seems to allow PHPUnit to run normally.

I've learnt the hard way that overriding core framework features like this always causes trouble.

Would you expect a PR that renames that helper function and it's usages within the app, and updates the readme to use the composer installed version of PHPUnit?


This comment has been minimized.

Copy link

commented Aug 4, 2019

Yeah, I know it's a bit awkward.

Laravel does make it's helper functions override-able which would generally be fine but yeah, issues are thrown when using the composer provided phpunit. Between the phpunit options, the difference lies in how they use the composer auto-loader. The composer-provided phpunit uses the same autoloader as the BookStack app whereas a downloaded phpunit does not depend on local vendor files. The composer-provided phpunit causes the laravel helper functions to be parsed before the BookStack helper functions, therefore throwing this error.

I've been working on updating the BookStack URL system anyway, to extend the laravel URL generator so the original laravel helpers can be used as normal. I'll update the title of this and leave it open as a reminder to update the testing instructions and ensure phpunit can be ran via composer after I've made changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
2 participants
You can’t perform that action at this time.