GithubHelp home page GithubHelp logo

Add Symfony PHPUnit bridge tool about toolbox HOT 17 CLOSED

ro0NL avatar ro0NL commented on September 28, 2024
Add Symfony PHPUnit bridge tool

from toolbox.

Comments (17)

jakzal avatar jakzal commented on September 28, 2024 2

It doesn't seem to work when I try to use it on a docker image. I'm getting the following error:

Fatal error: Declaration of Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerForV7::addError(PHPUnit\Framework\Test $test, Throwable $t, float $time): void must be compatible with PHPUnit\Framework\TestListener::addError(PHPUnit\Framework\Test $test, Exception $e, $time) in /tools/.composer/vendor-bin/symfony/vendor/symfony/phpunit-bridge/Legacy/SymfonyTestsListenerForV7.php on line 27

Tried it on PHP 7.3.

from toolbox.

ro0NL avatar ro0NL commented on September 28, 2024 1

@jakzal It's related to phpunit also being a dependency in the current project. I think we're hitting symfony/symfony#27289 (comment) actually

so the conflict seems expected, and in such case the real phpunit should be used (ref). I can confirm it works "as expected" then...

(given the current working directory is at your repo, which requires phpunit directly)

$ SYMFONY_PHPUNIT_VERSION=6.5 simple-phpunit     
PHP Fatal error:  Declaration of Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerForV7::addError...

$ cd build/

$ SYMFONY_PHPUNIT_VERSION=6.5 simple-phpunit
PHPUnit 6.5.13 by Sebastian Bergmann and contributors.

Usage: ...

to really confirm:

$ vendor/bin/phpunit --version
PHPUnit 7.5.1 by Sebastian Bergmann and contributors

$ composer remove --dev phpunit/phpunit zalas/phpunit-globals
# disable Zalas\PHPUnit\Globals\AnnotationListener in phpunit.xml.dist

$ SYMFONY_PHPUNIT_VERSION=6.5 simple-phpunit
PHPUnit 6.5.13 by Sebastian Bergmann and contributors.

...

So there's no conflict with phpunit from the toolbox, only when available as a project dependency.

This is a feature from simple-phpunit 😅 i dont think we need to wait and/or revert it from the toolbox. IMHO.

from toolbox.

jakzal avatar jakzal commented on September 28, 2024

Not sure how this could work. The bridge is meant to be included in project's dependencies. It takes care of preventing depdendency clashes etc. I'm not even sure if it was meant to be used standalone.

from toolbox.

ro0NL avatar ro0NL commented on September 28, 2024

I think that's a feature, not a requirement.

I just tried it as follow;

The current workding dir is /app/src/Domain which is a public composer package, without a dependency on symfony/phpunit-bridge

I've installed symfony/phpunit-bridge standalone in /app/var/tmp/composer.json

{
    "require-dev": {
        "symfony/phpunit-bridge": "*"
    }
}

Running it

www-data@3e85f8b4414d:/app/src/Domain$ SYMFONY_PHPUNIT_VERSION=7.5 ../../var/tmp/vendor/bin/simple-phpunit 
PHPUnit 7.5.1 by Sebastian Bergmann and contributors.

Testing msgphp/domain
..............

All good :)

from toolbox.

jakzal avatar jakzal commented on September 28, 2024

Sounds good then :) There's few features, like deprecation reports, that are worth having. 👍

from toolbox.

ro0NL avatar ro0NL commented on September 28, 2024

looks related to phpunit6 vs. php7, maybe we need to wait for a release symfony/symfony#29439.

Then again i didnt expect the current stable to be broken.. (https://github.com/symfony/symfony/blob/v4.2.2/src/Symfony/Bridge/PhpUnit/SymfonyTestsListener.php#L16)

ill try to build locally ASAP, to figure out what's going on. Perhaps @greg0ire knows...

from toolbox.

ro0NL avatar ro0NL commented on September 28, 2024

@jakzal for now running e.g. SYMFONY_PHPUNIT_VERSION=7.5 simple-phpunit does work, right?

from toolbox.

jakzal avatar jakzal commented on September 28, 2024

for now running e.g. SYMFONY_PHPUNIT_VERSION=7.5 simple-phpunit does work, right?

Yes, but it triggers installation.

from toolbox.

ro0NL avatar ro0NL commented on September 28, 2024

we install phpunit 6 by default still (https://travis-ci.com/jakzal/toolbox/jobs/170134793#L803). So that's intended, as you didnt have phpunit 7.5 yet.

im guessing there's some sort of autoloading conflict with the native phpunit binary, which is v7 already.

from toolbox.

jakzal avatar jakzal commented on September 28, 2024

im guessing there's some sort of autoloading conflict with the native phpunit binary, which is v7 already.

shouldn't be the case as we use the composer-bin-plugin, which intends to isolate dependencies :)

from toolbox.

jakzal avatar jakzal commented on September 28, 2024

re jakzal/phpqa#109

from toolbox.

jakzal avatar jakzal commented on September 28, 2024

I think it makes sense to wait for symfony/symfony#29439

from toolbox.

ro0NL avatar ro0NL commented on September 28, 2024

im guessing there's some sort of autoloading conflict with the native phpunit binary, which is v7 already.

shouldn't be the case as we use the composer-bin-plugin, which intends to isolate dependencies :)

was my guess also :) but im curious what happens at this point.. so 'll build the toolbox locally ASAP and follow the path.

I think it makes sense to wait for symfony/symfony#29439

think so :) yet it's only about new defaults for SYMFONY_PHPUNIT_VERSION, which you can provide manually today already. But the experience is not OK at the moment for sure :)

from toolbox.

ro0NL avatar ro0NL commented on September 28, 2024

reproduced locally also (php7.1), we definitely go from /var/www/.composer/vendor-bin/symfony/vendor/bin/.phpunit/phpunit-6.5/src to /app/vendor/phpunit/phpunit/src somehow..

    0.0627    5085408   5. Symfony\Bridge\PhpUnit\Legacy\TestRunnerForV7->doRun() /var/www/.composer/vendor-bin/symfony/vendor/bin/.phpunit/phpunit-6.5/src/TextUI/Command.php:195
    0.0627    5085432   6. Symfony\Bridge\PhpUnit\Legacy\TestRunnerForV7->handleConfiguration() /app/vendor/phpunit/phpunit/src/TextUI/TestRunner.php:160

still on it :)

from toolbox.

jakzal avatar jakzal commented on September 28, 2024

Thanks for getting into the bottom of this. I'm not exactly sure how phpunit bridge can be useful while it's installed this way, but let's give it a try 👍

from toolbox.

ro0NL avatar ro0NL commented on September 28, 2024

I'm not exactly sure how phpunit bridge can be useful while it's installed this way

the incompatibility with project dependencies definitely can hurt, but in this case you should either require phpunit/phpunit OR sf/phpunit-bridge. Having both in your project is pointless.

same for global vs. local phpunit, your project should rely on only 1 approach.

For example i have a monolith repo which holds N composer packages. I removed the simple-phpunit dependency from all of its packages, in favor of a global install in the monolith root. Now i can drop the global install too, in favor of the PHPQA toolbox.

from toolbox.

jakzal avatar jakzal commented on September 28, 2024

The latest tag of phpqa now also offers simple-phpunit: https://hub.docker.com/r/jakzal/phpqa/builds

Thanks @ro0NL!

from toolbox.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.