I want to test my application with phpunit. I have created a composer.json, a bootstrap.php file and a phpunit.xml. (all based on the app-tutorial btw. the mail app).
When I run the tests in my github source folder, bootstrapping failed. This is because in my bootstrap.php a bootstrap.php in the tests directory of the server is referenced. Therefore I assume, that I need to run my test somehow in my test server.
So I copied everything in my docker dev workspace/server/apps-extra folder and run the test there. But than it complains, that nextcloud is not installed.
So my question is, how should phpunit be used together with the nextcloud docker dev environment?
Even if @jlaba found a kind of solution, I want to repeat his question:
When using the app generator, the generated directory includes a composer.json with a test:unit script. Invoking that script with composer run "test:unit" results in
PHPUnit 10.5.35 by Sebastian Bergmann and contributors.
Error in bootstrap script: Exception:
Not installed
#0 /home/user/Projects/test/nextcloud-docker-dev/workspace/server/lib/base.php(675): OC::checkInstalled()
#1 /home/user/Projects/test/nextcloud-docker-dev/workspace/server/lib/base.php(1141): OC::init()
#2 /home/user/Projects/test/nextcloud-docker-dev/workspace/server/tests/bootstrap.php(14): require_once('...')
#3 /home/user/Projects/test/nextcloud-docker-dev/workspace/server/apps-extra/notebook/tests/bootstrap.php(5): require_once('...')
#4 /home/user/Projects/test/nextcloud-docker-dev/workspace/server/apps-extra/notebook/vendor-bin/phpunit/vendor/phpunit/phpunit/src/TextUI/Application.php(342): include_once('...')
#5 /home/user/Projects/test/nextcloud-docker-dev/workspace/server/apps-extra/notebook/vendor-bin/phpunit/vendor/phpunit/phpunit/src/TextUI/Application.php(107): PHPUnit\TextUI\Application->loadBootstrapScript()
#6 /home/user/Projects/test/nextcloud-docker-dev/workspace/server/apps-extra/notebook/vendor-bin/phpunit/vendor/phpunit/phpunit/phpunit(104): PHPUnit\TextUI\Application->run()
#7 /home/user/Projects/test/nextcloud-docker-dev/workspace/server/apps-extra/notebook/vendor/bin/phpunit(122): include('...')
Regarding
What exactly do you mean by this? Speaking for myself, I strictly followed the quickstart section of the nextcloud-docker-dev repo and the notebook tutorial, so the app itself is running.
Then you should be ready to go if you can generally access the app in the server.
However, you need a fully installed server, that is the DB must be reachable (simply speaking). This is only true if you use the PHP version as installed in the docker containers. If you just (outside the container) call composer test:unit (or similar), you use the PHP of you host OS and this will not have access to the DB in the same manner as the docker container (the DB is another docker container that is reachable only inside the docker compose bridge network).
This explains also why you need to run inside the containers.