#! /usr/bin/make -f

%:
	dh $@ --with=phpcomposer

execute_before_dh_auto_build:
	phpab --output Crypt/GPG/autoload.php ./Crypt
	mkdir --parents vendor
	phpabtpl \
		--require-file ../Crypt/GPG/autoload.php \
		>debian/autoload.tests.php.tpl
	phpab \
		--output vendor/autoload.php \
		--template debian/autoload.tests.php.tpl \
		tests

override_dh_install:
	dh_install -XREADME.md

override_dh_auto_test:
	# without --process-isolation there is a weird race condition
	# causing the tests to fails GnuPG when can't use /run/user/$UID as
	# socket directory (for instance because it's not there) and uses
	# its homedir as fallback -- removing the GNUPGHOME between each
	# test seems to cause problems when it contains the agent socket
	cp -vfT tests/config.php.dist tests/config.php
	sed -i 's/false/true/g' tests/config.php
	phpunit --bootstrap vendor/autoload.php ./tests \
			--process-isolation --exclude-group write
