Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TestSuite in events does not have proper name set #6108

Open
pawelbaranski opened this issue Jan 23, 2025 · 0 comments
Open

TestSuite in events does not have proper name set #6108

pawelbaranski opened this issue Jan 23, 2025 · 0 comments
Labels
type/bug Something is broken

Comments

@pawelbaranski
Copy link

Q A
PHPUnit version 10.5.41
PHP version 8.1.31
Installation Method Composer

Summary

I am using extension that registers subscriber, subscriber implements LoadedSubscriber (tried also with ExecutionStartedSubscriber, same result).

Current behavior

Loaded event that I'm getting has TestSuite object with name set with path to my phpunit.xml file instead of the test suite name that I run

How to reproduce

create extension

<?php

namespace My\Tests\extension;

use PHPUnit\Runner\Extension\Extension;
use PHPUnit\Runner\Extension\Facade;
use PHPUnit\Runner\Extension\ParameterCollection;
use PHPUnit\TextUI\Configuration\Configuration;

class RegisterSubscribersExtension implements Extension
{
	public function bootstrap(Configuration $configuration, Facade $facade, ParameterCollection $parameters): void
	{
		$facade->registerSubscribers(
			new IntegrationTestBootstrapExtension(),
		);
	}
}

create subscriber

<?php

namespace My\Tests\extension;

use PHPUnit\Event\TestRunner\ExecutionStarted;
use PHPUnit\Event\TestSuite\Loaded;
use PHPUnit\Event\TestSuite\LoadedSubscriber;

class IntegrationTestBootstrapExtension implements LoadedSubscriber
{
	public function notify(Loaded $event): void
	{
		var_dump($event->testSuite()->name());die;
	}
}

in phpunit.xml

<extensions>
    <bootstrap class="My\Tests\extension\RegisterSubscribersExtension"/>
</extensions>
<testsuites>
    <testsuite name="unit-panel">
    ...
    </testsuite>
    ...
</testsuites>

run tests (I run them with composer)

scripts in composer.json (I got it in "panel" subdirectory, relative to phpunit.xml)

"unit-tests": [
    "export APP=panel; phpunit -c ../phpunit.xml --testsuite=unit-panel"
],

run , with output

> composer -d panel unit-tests
> export APP=panel; phpunit -c ../phpunit.xml --testsuite=unit-panel
PHPUnit 10.5.41 by Sebastian Bergmann and contributors.

Runtime:       PHP 8.1.31
Configuration: /home/dev/public_html/phpunit.xml

/home/dev/public_html/tests/extension/IntegrationTestBootstrapExtension.php:13:
string(37) "/home/dev/public_html/phpunit.xml"

Expected behavior

I'd expect the TestSuite object to have name "unit-panel", not a path to phpunit.xml

@pawelbaranski pawelbaranski added the type/bug Something is broken label Jan 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug Something is broken
Projects
None yet
Development

No branches or pull requests

1 participant