diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 95eb97d61..6e2755201 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -52,8 +52,9 @@ All pull requests need to pass the tests and the code needs match the style guid To run the tests locally run: -- when testing using Docker: `docker-compose run --rm php make test` -- otherwise: `make test` +- when testing using Docker: `docker-compose run --rm php bin/phpunit` (or `docker-compose run --rm php make test` if you + prefer using `make`) +- otherwise: `bin/phpunit` (or `make test`) To run the PHP formatter: diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 7b5153cc0..1739c91c7 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -75,11 +75,8 @@ jobs: with: composer-options: "--optimize-autoloader --prefer-dist" - - name: "Prepare database" - run: "make prepare DB=${{ matrix.database }}" - - - name: "Prepare fixtures" - run: "make fixtures" + - name: "Prepare database configuration" + run: cp app/config/tests/parameters_test.${{ matrix.database }}.yml app/config/parameters_test.yml - name: "Run PHPUnit" run: "php bin/phpunit -v" @@ -146,11 +143,8 @@ jobs: with: composer-options: "--optimize-autoloader --prefer-dist" - - name: "Prepare database" - run: "make prepare DB=${{ matrix.database }}" - - - name: "Prepare fixtures" - run: "make fixtures" + - name: "Prepare database configuration" + run: cp app/config/tests/parameters_test.${{ matrix.database }}.yml app/config/parameters_test.yml - name: "Run PHPUnit" run: "php bin/phpunit -v" diff --git a/GNUmakefile b/GNUmakefile index 56b09638b..1af36780b 100755 --- a/GNUmakefile +++ b/GNUmakefile @@ -14,9 +14,6 @@ endif help: ## Display this help menu @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' -clean: ## Clear the application cache - rm -rf var/cache/* - install: ## Install wallabag with the latest version @./scripts/install.sh $(ENV) @@ -34,18 +31,7 @@ build: ## Run webpack @yarn install @yarn build:$(ENV) -prepare: clean ## Prepare database for testsuite -ifdef DB - cp app/config/tests/parameters_test.$(DB).yml app/config/parameters_test.yml -endif - -php bin/console doctrine:database:drop --force --env=test - php bin/console doctrine:database:create --env=test - php bin/console doctrine:migrations:migrate --no-interaction --env=test -vv - -fixtures: ## Load fixtures into database - php bin/console doctrine:fixtures:load --no-interaction --env=test - -test: prepare fixtures ## Launch wallabag testsuite +test: ## Launch wallabag testsuite XDEBUG_MODE=off php -dmemory_limit=-1 bin/phpunit -v release: ## Create a package. Need a VERSION parameter (eg: `make release VERSION=master`). @@ -57,6 +43,6 @@ endif deploy: ## Deploy wallabag @bundle exec cap staging deploy -.PHONY: help clean prepare install fixtures update build test release deploy run dev +.PHONY: help install update build test release deploy run dev .DEFAULT_GOAL := install diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 79b48462d..6cdcea71c 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -4,7 +4,7 @@ xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.8/phpunit.xsd" backupGlobals="false" colors="true" - bootstrap="vendor/autoload.php" + bootstrap="tests/bootstrap.php" > diff --git a/tests/bootstrap.php b/tests/bootstrap.php new file mode 100644 index 000000000..a84eb8700 --- /dev/null +++ b/tests/bootstrap.php @@ -0,0 +1,48 @@ +remove(__DIR__ . '/../var/cache/test'); + +(new Process([ + 'php', + __DIR__ . '/../bin/console', + 'doctrine:database:drop', + '--force', + '--env=test', +]))->run(function ($type, $buffer) { + echo $buffer; +}); + +(new Process([ + 'php', + __DIR__ . '/../bin/console', + 'doctrine:database:create', + '--env=test', +]))->mustRun(function ($type, $buffer) { + echo $buffer; +}); + +(new Process([ + 'php', + __DIR__ . '/../bin/console', + 'doctrine:migrations:migrate', + '--no-interaction', + '--env=test', + '-vv', +]))->mustRun(function ($type, $buffer) { + echo $buffer; +}); + +(new Process([ + 'php', + __DIR__ . '/../bin/console', + 'doctrine:fixtures:load', + '--no-interaction', + '--env=test', +]))->mustRun(function ($type, $buffer) { + echo $buffer; +});