# Copyright 1999-2026 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=9

COMPOSER_INSTALL_PATH="SebastianBergmann/PHPCOV"
PHP_MIN_VER="8.3"

inherit composer git-r3

DESCRIPTION="TextUI frontend for php-code-coverage"
HOMEPAGE="https://github.com/sebastianbergmann/phpcov"
EGIT_REPO_URI="https://github.com/sebastianbergmann/phpcov.git"

LICENSE="BSD"
SLOT="0"

RDEPEND="dev-php/phpunit
	dev-php/phpunit-php-code-coverage
	dev-php/phpunit-php-file-iterator
	dev-php/sebastian-cli-parser
	dev-php/sebastian-diff
	dev-php/sebastian-version"
BDEPEND="test? ( dev-php/xdebug )"

DOCS=( {ChangeLog,README}.md )

composer_enable_tests phpunit

src_test() {
	XDEBUG_MODE=coverage edo phpunit -c tests/fixture/example/phpunit.xml --filter '::testGreetsWorld$' \
		--coverage-php tests/fixture/example/coverage/testGreetsWorld.cov
	XDEBUG_MODE=coverage edo phpunit -c tests/fixture/example/phpunit.xml --filter '::testGreetsWithName$' \
		--coverage-php tests/fixture/example/coverage/testGreetsWithName.cov
	XDEBUG_MODE=coverage ephpunit
}

src_install() {
	composer_src_install

	exeinto /usr/share/php/"${COMPOSER_INSTALL_PATH}"
	doexe phpcov
	dosym ../share/php/"${COMPOSER_INSTALL_PATH}"/phpcov \
		/usr/bin/phpcov
}