Hi, I've found a problem with using custom Comparator, and made a workaround - I'm writing to make others aware of this issue.
In my tests I registered a custom Comparator using SebastianBergmann\Comparator\Factory (as I read in the phpunit doc), but it didn't work with php-actions/phpunit
As I found out, the phpunit PHAR prefixes the SebastianBergmann namespace with PHPUnitPhar
I did the following workaround in my phpunit bootstrap.php - this way the tests run both using the phpunit in vendor directory, and with the phpunit PHAR. (Though it might be better to drop the phpunit from vendor, and always use phpunit PHAR.)
useSebastianBergmann\Comparator\FactoryasComparatorFactory;
usePHPUnitPHAR\SebastianBergmann\Comparator\FactoryasPharComparatorFactory;
if (class_exists(PharComparatorFactory::class)) {
$comparatorFactory = PharComparatorFactory::class;
// alias PHPUnit classes used in my custom TzunghaorObjectComparator class_alias(PHPUnitPHAR\SebastianBergmann\Comparator\Comparator::class, 'SebastianBergmann\Comparator\Comparator');
class_alias(PHPUnitPhar\SebastianBergmann\Comparator\ComparisonFailure::class, 'SebastianBergmann\Comparator\ComparisonFailure');
} elseif (class_exists(ComparatorFactory::class)) {
$comparatorFactory = ComparatorFactory::class;
} else {
thrownewRuntimeException('SebastianBergmann\Comparator\Factory not found');
}
$comparatorFactory::getInstance()->register(newTzunghaorObjectComparator());
Hi, I've found a problem with using custom Comparator, and made a workaround - I'm writing to make others aware of this issue.
In my tests I registered a custom Comparator using SebastianBergmann\Comparator\Factory (as I read in the phpunit doc), but it didn't work with php-actions/phpunit
As I found out, the phpunit PHAR prefixes the SebastianBergmann namespace with PHPUnitPhar
I did the following workaround in my phpunit bootstrap.php - this way the tests run both using the phpunit in vendor directory, and with the phpunit PHAR. (Though it might be better to drop the phpunit from vendor, and always use phpunit PHAR.)