In the notestutorial app there is code for unit and integration testing included. Tests can be run conveniently through gmake test
.
Unfortunately, I get an error message saying:
PHP Warning: require_once(/usr/local/www/devcloud/apps/notestutorial/tests/../../../tests/bootstrap.php): failed to open stream: No such file or directory in /usr/local/www/devcloud/apps/notestutorial/tests/bootstrap.php on line 3
From the the dev docs and the core dev docs I understand that in order for phpunit to find any of the classes under test the NC environment needs to be bootstrapped.
I could not find the explicit --bootstrap
directive but the tests/bootstrap.php
file seems to be have that purpose. It contains only one line which appears to point nowhere reasonnable:
require_once __DIR__ . '/../../../tests/bootstrap.php';
It seemed the file pointed to itself (and missed) so I commented out the statement. Current error is that the NC classes cannot be found:
[user@host /usr/local/www/devcloud/apps/notestutorial]$ gmake test
./vendor/phpunit/phpunit/phpunit -c phpunit.xml
PHP Fatal error: Uncaught Error: Class 'OCA\NotesTutorial\Tests\Unit\Controller\NoteControllerTest' not found in /usr/local/www/devcloud/apps/notestutorial/tests/Unit/Controller/NoteApiControllerTest.php:7
Stack trace:
#0 /usr/local/www/devcloud/apps/notestutorial/vendor/phpunit/phpunit/src/Util/FileLoader.php(66): include_once()
#1 /usr/local/www/devcloud/apps/notestutorial/vendor/phpunit/phpunit/src/Util/FileLoader.php(54): PHPUnit\Util\FileLoader::load('/usr/local/www/...')
#2 /usr/local/www/devcloud/apps/notestutorial/vendor/phpunit/phpunit/src/Framework/TestSuite.php(383): PHPUnit\Util\FileLoader::checkAndLoad('/usr/local/www/...')
#3 /usr/local/www/devcloud/apps/notestutorial/vendor/phpunit/phpunit/src/Framework/TestSuite.php(481): PHPUnit\Framework\TestSuite->addTestFile('/usr/local/www/...')
#4 /usr/local/www/devcloud/apps/notestutorial/vendor/phpunit/phpunit/src/Util/Configuration.php(1031): PHPUnit\Framework\TestSuite->addTestFiles(Array)
#5 /usr/local/www/devcloud/apps/notestutorial/vendor/phpunit/phpunit/src/Util/ in /usr/local/www/devcloud/apps/notestutorial/tests/Unit/Controller/NoteApiControllerTest.php on line 7
What must I do to make the NC classes available to phpunit?