#!/usr/bin/make -f

%:
	dh $@ --with phpcomposer

override_dh_auto_build:
	# generate static autoloader
	phpab \
		--output src/ReCaptcha/autoload.php \
		src/ReCaptcha
	# generate outoload-files. keep in sync with debian/tests/phpunit
	phpab --template debian/autoload-test.php.tpl \
		--output tests/autoload.php \
		tests

override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	# keep in sync with debian/tests/phpunit
	find tests/ -type f -print0 | xargs -0 sed -i 's/function setUp()/function setUp(): void/g'
	find tests/ -type f -print0 | xargs -0 sed -i 's/function tearDown()/function tearDown(): void/g'
	# Adding --include-path at build time allows src/ReCaptcha/autoload.php to
	# be found, while ReCaptcha/autoload.php from the installed package under
	# /usr/share/php/ will be used during autopkgtest.
	phpunit --no-coverage --bootstrap tests/autoload.php --include-path src
	find tests/ -type f -print0 | xargs -0 sed -i 's/function setUp(): void/function setUp()/g'
	find tests/ -type f -print0 | xargs -0 sed -i 's/function tearDown(): void/function tearDown()/g'
endif
