symfony / recipes

Symfony Recipes Repository
https://github.com/symfony/recipes/blob/flex/main/RECIPES.md
MIT License
979 stars 481 forks source link

Class "PHPUnit\TextUI\Command" not found #1248

Closed jawira closed 1 year ago

jawira commented 1 year ago

Symfony version(s) affected

v6.3

Description

When I execute php bin/phpunit I get the following exception:

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

How to reproduce

Here's what I did:

  1. I created a new project with Symfony command: symfony new my-project.
  2. After some days of work I installed test-pack with composer require test.
  3. Then I followed terminal instructions and created a new test bin/console make:test.
  4. Finally I tried to execute the test with php bin/phpunit. Fatal error raises.

Possible Solution

Well, as the error suggests PHPUnit\TextUI\Command does not exists, so I checked composer.json and PHPUnit v10.4 was installed, so I downgraded to PHPUnit v9 :

$ composer require phpunit/phpunit:^9 --dev -W

And the error was fixed.

Additional Context

In this specific project PHPUnit v10 is always installed, I tried to reproduce the error in a fresh project and PHPUnit v9 was installed.

Anyway, after a quick revision, I noticed that PHPUnit version is never specified by Symfony, IMHO this should be done in symfony/phpunit-bridge to avoid installing PHPUnit v10 since PHPUnit\TextUI\Command exists no more.

Thank you :)

ghost commented 1 year ago

The test pack has phpunit locked at ^9.5 (https://github.com/symfony/test-pack/blob/main/composer.json). Also the recipie for symfony/phpunit-bridge has SYMFONY_PHPUNIT_VERSION set to 9.5 (https://github.com/symfony/recipes/blob/main/symfony/phpunit-bridge/6.3/phpunit.xml.dist). So it's very unlikely you could have had v10 installed.

Please debug more what could happen in your application or provide a reproducer.

xabbuh commented 1 year ago

What does composer show output? If it lists phpunit/phunit please run composer why phpunit/phpunit and also share the output.

wouterj commented 1 year ago

This is a bug in the recipe that I also encountered. Issue occurs when not using the PHPunit bridge, but installing phpunit/phpunit. The bin/phpunit script from the recipe should be updated to support newer PHPunit versions.

derrabus commented 1 year ago

If I don't want the bridge to manage my PHPUnit installation, why would I want to use the bin/phpunit script anyway?

ghost commented 1 year ago

The OP says:

This is physically impossible.

derrabus commented 1 year ago

I've moved the issue since it's obviously a recipe related problem.

derrabus commented 1 year ago

PR: #1249

jawira commented 1 year ago

What does composer show output? If it lists phpunit/phunit please run composer why phpunit/phpunit and also share the output.

Composer show:

$ composer show
amphp/amp                             v2.6.2  A non-blocking concurrency framework for PHP a...
amphp/byte-stream                     v1.8.1  A stream abstraction to make working with non-...
composer/pcre                         3.1.1   PCRE wrapping library that offers type-safe pr...
composer/semver                       3.4.0   Semver library that offers utilities, version ...
composer/xdebug-handler               3.0.3   Restarts a process without Xdebug.
dnoegel/php-xdg-base-dir              v0.1.1  implementation of xdg base directory specifica...
doctrine/cache                        2.2.0   PHP Doctrine Cache library is a popular cache ...
doctrine/collections                  2.1.4   PHP Doctrine Collections library that adds add...
doctrine/common                       3.4.3   PHP Doctrine Common project is a library that ...
doctrine/data-fixtures                1.6.7   Data Fixtures for all Doctrine Object Managers
doctrine/dbal                         3.7.1   Powerful PHP database abstraction layer (DBAL)...
doctrine/deprecations                 1.1.2   A small layer on top of trigger_error(E_USER_D...
doctrine/doctrine-bundle              2.10.2  Symfony DoctrineBundle
doctrine/doctrine-migrations-bundle   3.2.4   Symfony DoctrineMigrationsBundle
doctrine/event-manager                2.0.0   The Doctrine Event Manager is a simple PHP eve...
doctrine/inflector                    2.0.8   PHP Doctrine Inflector is a small library that...
doctrine/instantiator                 2.0.0   A small, lightweight utility to instantiate ob...
doctrine/lexer                        2.1.0   PHP Doctrine Lexer parser library that can be ...
doctrine/migrations                   3.6.0   PHP Doctrine Migrations project offer addition...
doctrine/orm                          2.16.2  Object-Relational-Mapper for PHP
doctrine/persistence                  3.2.0   The Doctrine Persistence project is a set of s...
doctrine/sql-formatter                1.1.3   a PHP SQL highlighting library
ergebnis/composer-normalize           2.30.0  Provides a composer plugin for normalizing com...
ergebnis/json                         1.1.0   Provides a Json value object for representing ...
ergebnis/json-normalizer              4.0.2   Provides generic and vendor-specific normalize...
ergebnis/json-pointer                 3.3.0   Provides JSON pointer as a value object.
ergebnis/json-printer                 3.4.0   Provides a JSON printer, allowing for flexible...
ergebnis/json-schema-validator        4.1.0   Provides a JSON schema validator, building on ...
fakerphp/faker                        v1.23.0 Faker is a PHP library that generates fake dat...
felixfbecker/advanced-json-rpc        v3.2.1  A more advanced JSONRPC implementation
felixfbecker/language-server-protocol v1.5.2  PHP classes for the Language Server Protocol
fidry/cpu-core-counter                0.5.1   Tiny utility to get the number of CPU cores.
friendsofphp/php-cs-fixer             v3.37.1 A tool to automatically fix PHP code style
hautelook/alice-bundle                2.12.1  Symfony bundle to manage fixtures with Alice a...
jawira/db-draw                        v1.4.0  📐 Takes a DoctrineORM connection and genera...
jawira/doctrine-diagram-bundle        v0.4.0  📐 Symfony Bundle to generate database diagrams
jawira/plantuml-client                v1.0.3  Convert PlantUML diagrams into images.
jawira/plantuml-encoding              v1.1.0  PlantUML encoding functions
jawira/skeleton                       v2.20.0  Common Phing targets I use in all my projects
jawira/the-lost-functions             v1.6.0  Collection of convenience functions.
justinrainbow/json-schema             v5.2.13 A library to validate a json schema.
localheinz/diff                       1.1.1   Fork of sebastian/diff for use with ergebnis/c...
masterminds/html5                     2.8.1   An HTML5 parser and serializer.
myclabs/deep-copy                     1.11.1  Create deep copies (clones) of your objects
nelmio/alice                          3.12.2  Expressive fixtures generator
netresearch/jsonmapper                v4.2.0  Map nested JSON structures onto PHP classes
nikic/php-parser                      v4.17.1 A PHP parser written in PHP
phar-io/manifest                      2.0.3   Component for reading phar.io manifest informa...
phar-io/version                       3.2.1   Library for handling version information and c...
phpdocumentor/reflection-common       2.2.0   Common reflection classes used by phpdocumento...
phpdocumentor/reflection-docblock     5.3.0   With this component, a library can provide sup...
phpdocumentor/type-resolver           1.7.3   A PSR-5 based resolver of Class names, Types a...
phpstan/phpdoc-parser                 1.24.2  PHPDoc parser with support for nullable, inter...
phpunit/php-code-coverage             10.1.7  Library that provides collection, processing, ...
phpunit/php-file-iterator             4.1.0   FilterIterator implementation that filters fil...
phpunit/php-invoker                   4.0.0   Invoke callables with a timeout
phpunit/php-text-template             3.0.1   Simple template engine.
phpunit/php-timer                     6.0.0   Utility class for timing
phpunit/phpunit                       10.4.2  The PHP Unit Testing framework.
psalm/plugin-symfony                  v5.0.3  Psalm Plugin for Symfony
psr/cache                             3.0.0   Common interface for caching libraries
psr/clock                             1.0.0   Common interface for reading the clock.
psr/container                         2.0.2   Common Container Interface (PHP FIG PSR-11)
psr/event-dispatcher                  1.0.0   Standard interfaces for event handling.
psr/log                               3.0.0   Common interface for logging libraries
sebastian/cli-parser                  2.0.0   Library for parsing CLI options
sebastian/code-unit                   2.0.0   Collection of value objects that represent the...
sebastian/code-unit-reverse-lookup    3.0.0   Looks up which function or method a line of co...
sebastian/comparator                  5.0.1   Provides the functionality to compare PHP valu...
sebastian/complexity                  3.1.0   Library for calculating the complexity of PHP ...
sebastian/diff                        5.0.3   Diff implementation
sebastian/environment                 6.0.1   Provides functionality to handle HHVM/PHP envi...
sebastian/exporter                    5.1.1   Provides the functionality to export PHP varia...
sebastian/global-state                6.0.1   Snapshotting of global state
sebastian/lines-of-code               2.0.1   Library for counting the lines of code in PHP ...
sebastian/object-enumerator           5.0.0   Traverses array structures and object graphs t...
sebastian/object-reflector            3.0.0   Allows reflection of object attributes, includ...
sebastian/recursion-context           5.0.0   Provides functionality to recursively process ...
sebastian/type                        4.0.0   Collection of value objects that represent the...
sebastian/version                     4.0.1   Library that helps with managing the version n...
spatie/array-to-xml                   3.2.0   Convert an array to xml
symfony/browser-kit                   v6.3.2  Simulates the behavior of a web browser, allow...
symfony/cache                         v6.3.6  Provides extended PSR-6, PSR-16 (and tags) imp...
symfony/cache-contracts               v3.3.0  Generic abstractions related to caching
symfony/clock                         v6.3.4  Decouples applications from the system clock
symfony/config                        v6.3.2  Helps you find, load, combine, autofill and va...
symfony/console                       v6.3.4  Eases the creation of beautiful and testable c...
symfony/css-selector                  v6.3.2  Converts CSS selectors to XPath expressions
symfony/dependency-injection          v6.3.5  Allows you to standardize and centralize the w...
symfony/deprecation-contracts         v3.3.0  A generic function and convention to trigger d...
symfony/doctrine-bridge               v6.3.7  Provides integration for Doctrine with various...
symfony/dom-crawler                   v6.3.4  Eases DOM navigation for HTML and XML documents
symfony/dotenv                        v6.3.7  Registers environment variables from a .env file
symfony/error-handler                 v6.3.5  Provides tools to manage errors and ease debug...
symfony/event-dispatcher              v6.3.2  Provides tools that allow your application com...
symfony/event-dispatcher-contracts    v3.3.0  Generic abstractions related to dispatching event
symfony/filesystem                    v6.3.1  Provides basic utilities for the filesystem
symfony/finder                        v6.3.5  Finds files and directories via an intuitive f...
symfony/flex                          v2.4.1  Composer plugin for Symfony
symfony/framework-bundle              v6.3.7  Provides a tight integration between Symfony c...
symfony/http-foundation               v6.3.7  Defines an object-oriented layer for the HTTP ...
symfony/http-kernel                   v6.3.7  Provides a structured process for converting a...
symfony/maker-bundle                  v1.51.1 Symfony Maker helps you create empty commands,...
symfony/options-resolver              v6.3.0  Provides an improved replacement for the array...
symfony/password-hasher               v6.3.5  Provides password hashing utilities
symfony/phpunit-bridge                v6.3.6  Provides utilities for PHPUnit, especially use...
symfony/polyfill-intl-grapheme        v1.28.0 Symfony polyfill for intl's grapheme_* functions
symfony/polyfill-intl-normalizer      v1.28.0 Symfony polyfill for intl's Normalizer class a...
symfony/polyfill-mbstring             v1.28.0 Symfony polyfill for the Mbstring extension
symfony/polyfill-php83                v1.28.0 Symfony polyfill backporting some PHP 8.3+ fea...
symfony/process                       v6.3.4  Executes commands in sub-processes
symfony/property-access               v6.3.2  Provides functions to read and write from/to a...
symfony/property-info                 v6.3.0  Extracts information about PHP class' properti...
symfony/routing                       v6.3.5  Maps an HTTP request to a set of configuration...
symfony/runtime                       v6.3.2  Enables decoupling PHP applications from globa...
symfony/security-bundle               v6.3.7  Provides a tight integration of the Security c...
symfony/security-core                 v6.3.7  Symfony Security Component - Core Library
symfony/security-csrf                 v6.3.2  Symfony Security Component - CSRF Library
symfony/security-http                 v6.3.6  Symfony Security Component - HTTP Integration
symfony/service-contracts             v3.3.0  Generic abstractions related to writing services
symfony/stopwatch                     v6.3.0  Provides a way to profile code
symfony/string                        v6.3.5  Provides an object-oriented API to strings and...
symfony/var-dumper                    v6.3.6  Provides mechanisms for walking through any ar...
symfony/var-exporter                  v6.3.6  Allows exporting any serializable PHP data str...
symfony/yaml                          v6.3.7  Loads and dumps YAML files
theofidry/alice-data-fixtures         1.6.0   Nelmio alice extension to persist the loaded f...
theseer/tokenizer                     1.2.1   A small library for converting tokenized PHP s...
vimeo/psalm                           5.15.0  A static analysis tool for finding errors in P...
webmozart/assert                      1.11.0  Assertions to validate method input/output wit...
weirdan/doctrine-psalm-plugin         v2.9.0  Stubs to let Psalm understand Doctrine better

Composer why :

$ composer why phpunit/phpunit
overflow/overflow      dev-main requires (for development) phpunit/phpunit (^10.4)      
symfony/phpunit-bridge v6.3.6   conflicts                  phpunit/phpunit (<7.5|9.1.2)