diff --git a/.gitignore b/.gitignore index 55d9dd391..957307d54 100644 --- a/.gitignore +++ b/.gitignore @@ -24,4 +24,5 @@ cypress/videos cypress/snapshots cypress/downloads -js/*hot-update.* \ No newline at end of file +js/*hot-update.* +tests/.phpunit.result.cache diff --git a/composer.json b/composer.json index cf8cad5b4..fa8ab37f6 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,7 @@ "psalm:update-baseline": "psalm.phar --threads=1 --update-baseline", "psalm:clear": "psalm.phar --clear-cache && psalm --clear-global-cache", "psalm:fix": "psalm.phar --alter --issues=InvalidReturnType,InvalidNullableReturnType,MissingParamType,InvalidFalsableReturnType", - "test:unit": "echo 'Only testing installation of the app'" + "test:unit": "vendor/bin/phpunit -c tests/phpunit.xml --color --fail-on-warning --fail-on-risky" }, "require-dev": { "bamarni/composer-bin-plugin": "^1.8", diff --git a/tests/bootstrap.php b/tests/bootstrap.php new file mode 100644 index 000000000..d00c2737b --- /dev/null +++ b/tests/bootstrap.php @@ -0,0 +1,39 @@ + + * @author Jörn Friedrich Dreyer + * + * @license AGPL-3.0 + * + * This code is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License, version 3, + * along with this program. If not, see + * + */ +if (!defined('PHPUNIT_RUN')) { + define('PHPUNIT_RUN', 1); +} + +require_once __DIR__.'/../../../lib/base.php'; + +// Fix for "Autoload path not allowed: .../tests/lib/testcase.php" +\OC::$loader->addValidRoot(OC::$SERVERROOT . '/tests'); + +// Fix for "Autoload path not allowed: .../activity/tests/testcase.php" +\OC_App::loadApp('photos'); + +if (!class_exists('\PHPUnit\Framework\TestCase')) { + require_once('PHPUnit/Autoload.php'); +} + +OC_Hook::clear(); diff --git a/tests/phpunit.xml b/tests/phpunit.xml new file mode 100644 index 000000000..3e7c2ec9c --- /dev/null +++ b/tests/phpunit.xml @@ -0,0 +1,13 @@ + + + + . + + +