symfony / test-pack

A Symfony Pack for functional testing
MIT License
857 stars 9 forks source link

Adding phpunit dependency to test-pack breaks phpunit-bridge #12

Closed GPHemsley-RELX closed 3 years ago

GPHemsley-RELX commented 3 years ago

My package has a dev dependency on both symfony/phpunit-bridge and symfony/test-pack. I run my tests with vendor/bin/simple-phpunit.

After updating to test-pack 1.0.8, which adds a direct dependency on phpunit/phpunit, my tests no longer run, as invoking simple-phpunit immediately fails with an error:

PHP Fatal error:  Uncaught Error: Cannot instantiate interface PHPUnit\TextUI\Exception in /.../vendor/bin/.phpunit/phpunit-9.3-0/src/TextUI/Command.php:103
Stack trace:
#0 /.../vendor/bin/.phpunit/phpunit-9.3-0/phpunit(22): PHPUnit\TextUI\Command::main()
#1 /.../vendor/symfony/phpunit-bridge/bin/simple-phpunit.php(428): include('/......')
#2 /.../vendor/bin/simple-phpunit(21) : eval()'d code(12): require('/......')
#3 /.../vendor/bin/simple-phpunit(21): eval()
#4 {main}
  thrown in /.../vendor/bin/.phpunit/phpunit-9.3-0/src/TextUI/Command.php on line 103

I am running Symfony 4.4 on PHP 7.4.

nicolas-grekas commented 3 years ago

You need to unpack the pack and manage your deps explicitly.

GPHemsley-RELX commented 3 years ago

@nicolas-grekas Are you saying this is by design?

nicolas-grekas commented 3 years ago

Yes: packs are now unpacked by default to let ppl manage their deps explicitly. Please upgrade flex and unpack packs if you started your project before this change.

GPHemsley-RELX commented 3 years ago

Is there documentation for this? How can I tell if a package is a pack?

Kocal commented 3 years ago

If the field type from its composer.json is equal to symfony-pack, see https://github.com/symfony/test-pack/blob/main/composer.json#L3

nicolas-grekas commented 3 years ago

Also, packs always have the -pack suffix. You might want to check https://github.com/symfony/flex/pull/655 and to run composer help unpack

Ak1r0 commented 1 year ago

I think there is a still a problem with this design because following the symfony testing documentation exposes us to breaking changes.

PHP Fatal error:  Uncaught Error: Class "PHPUnit\TextUI\Command" not found in /srv/app/bin/phpunit:11
Stack trace:
#0 {main}
  thrown in /srv/app/bin/phpunit on line 11

The PHPUnit\TextUI\Command class In PHPUnit 9.6.1 has been removed in PHPUnit 10.0.0

Just spent an hour to understand I have to downgrade the PHPUnit version autmaticaly installed

tricsusz commented 1 year ago

I think there is a still a problem with this design because following the symfony testing documentation exposes us to breaking changes.

PHP Fatal error:  Uncaught Error: Class "PHPUnit\TextUI\Command" not found in /srv/app/bin/phpunit:11
Stack trace:
#0 {main}
  thrown in /srv/app/bin/phpunit on line 11

The PHPUnit\TextUI\Command class In PHPUnit 9.6.1 has been removed in PHPUnit 10.0.0

Just spent an hour to understand I have to downgrade the PHPUnit version autmaticaly installed

Agree! I spent 2 hours debugging