nextcloud / cms_pico

🗃 Integrate Pico CMS and let your users manage their own websites
https://apps.nextcloud.com/apps/cms_pico
GNU Affero General Public License v3.0
137 stars 43 forks source link

unable to execute unit tests #231

Closed derMart closed 1 year ago

derMart commented 1 year ago

Hey, in preparation for creating a pull requests to upstream for pico3 I tried to run the unit tests in a clean installation of the current master branch (https://github.com/nextcloud/cms_pico/commit/cf9edc137285153c6474ea80aef4eb7da1ea1fa6). This is the outcome:

php -f ./vendor/bin/phpunit -- --configuration ./tests/phpunit.xml
PHP Warning:  require_once(/home/martin/repos/cms_pico/tests/../../../lib/base.php): Failed to open stream: No such file or directory in /home/martin/repos/cms_pico/tests/bootstrap.php on line 27
PHP Fatal error:  Uncaught Error: Failed opening required '/home/martin/repos/cms_pico/tests/../../../lib/base.php' (include_path='.:/usr/share/php') in /home/martin/repos/cms_pico/tests/bootstrap.php:27
Stack trace:
#0 /home/martin/repos/cms_pico/vendor/phpunit/phpunit/src/Util/FileLoader.php(66): include_once()
#1 /home/martin/repos/cms_pico/vendor/phpunit/phpunit/src/Util/FileLoader.php(54): PHPUnit\Util\FileLoader::load()
#2 /home/martin/repos/cms_pico/vendor/phpunit/phpunit/src/TextUI/Command.php(1126): PHPUnit\Util\FileLoader::checkAndLoad()
#3 /home/martin/repos/cms_pico/vendor/phpunit/phpunit/src/TextUI/Command.php(922): PHPUnit\TextUI\Command->handleBootstrap()
#4 /home/martin/repos/cms_pico/vendor/phpunit/phpunit/src/TextUI/Command.php(202): PHPUnit\TextUI\Command->handleArguments()
#5 /home/martin/repos/cms_pico/vendor/phpunit/phpunit/src/TextUI/Command.php(194): PHPUnit\TextUI\Command->run()
#6 /home/martin/repos/cms_pico/vendor/phpunit/phpunit/phpunit(98): PHPUnit\TextUI\Command::main()
#7 /home/martin/repos/cms_pico/vendor/bin/phpunit(123): include('...')
#8 {main}
  thrown in /home/martin/repos/cms_pico/tests/bootstrap.php on line 27
make: *** [Makefile:156: test] Error 255

And in fact, bootstrap.php is refering to some file outside of the repo root: https://github.com/nextcloud/cms_pico/blob/cf9edc137285153c6474ea80aef4eb7da1ea1fa6/tests/bootstrap.php#L27

PhrozenByte commented 1 year ago

The app's unit tests (not really unit tests, rather integration tests) don't run standalone, but require a working dev install of Nextcloud. You must have your cms_pico repo below some folder (usually apps, or apps_dev, or something similar) of a Nextcloud dev install (e.g. /var/www/nextcloud/apps_dev/cms_pico, so that PHPUnit can include /var/www/nextcloud/lib/base.php).

Please note that the tests unfortunately aren't 100% safe not to modify your dev install on PHP Fatal Errors (we'd need a overlayfs to do so...), so sometimes temporary stuff survives. occ maintenance:repair will usually fix any issues with the database and appdata_public, but data/appdata_*/cms_pico needs to be cleaned manually. I tried fixing this by temporarily changing Nextcloud's data path, but never got it working... I recommend keeping a backup around, makes things easier.

Will look into your PRs soon, thank you for your contributions! :heart:

github-actions[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in two days if no further activity occurs. Thank you for your contributions! :+1: