Logo

dev-resources.site

for different kinds of informations.

Fix Symfony tests with PHPUnit 10

Published at
2/8/2023
Categories
symfony
phpunit
testing
tests
Author
manuelcanga
Categories
4 categories in total
symfony
open
phpunit
open
testing
open
tests
open
Author
11 person written this
manuelcanga
open
Fix Symfony tests with PHPUnit 10

Maybe, In your Symfony project, you tried to run something as:

$ php bin/phpunit
Enter fullscreen mode Exit fullscreen mode

and you had as result this ugly message (or similar):

PHP Fatal error: Uncaught Error: Class "PHPUnit\TextUI \Command" not found in /var/www/html/yourproject/bin/phpunit:12
Stack trace:
#0 {main}
thrown in /var/www/html/yourproject/bin/phpunit on line 12

Don't worry. Edit your bin/phpunit file and rewrite it with the following content:

#!/usr/bin/env php
<?php

if (!ini_get('date.timezone')) {
    ini_set('date.timezone', 'UTC');
}


if (is_file(dirname(__DIR__).'/vendor/phpunit/phpunit/phpunit')) {
    define('PHPUNIT_COMPOSER_INSTALL', dirname(__DIR__).'/vendor/autoload.php');
    require PHPUNIT_COMPOSER_INSTALL;

exit((new \PHPUnit\TextUI\Application())->run($GLOBALS['argv']));
} else {
    if (!is_file(dirname(__DIR__).'/vendor/symfony/phpunit-bridge/bin/simple-phpunit.php')) {
        echo "Unable to find the `simple-phpunit.php` script in `vendor/symfony/phpunit-bridge/bin/`.\n";
        exit(1);
    }

    require dirname(__DIR__).'/vendor/symfony/phpunit-bridge/bin/simple-phpunit.php';
}
Enter fullscreen mode Exit fullscreen mode

Happy codding!


tests Article's
30 articles in total
Favicon
Sufficient Software Tests Using Metrics
Favicon
Exploring the Benefits of Integration Testing
Favicon
Best Practices for Effective Automated Integration Tests
Favicon
Automated Tests instrumentation via OpenTelemetry and Aspire Dashboard
Favicon
Integrated tests... are they really important?
Favicon
Focusing on high code coverage can be a trap
Favicon
5 Mistakes to Avoid While Writing Integration Tests
Favicon
Reaching an improved realistic testing approach in the Laravel feature test
Favicon
Desafios Comuns na Escrita de Testes Automatizados: Rumo à Clareza e Padronização - Parte 1
Favicon
Artigo Software Testing: A Research Travelogue - Resumo em PT-BR
Favicon
QA - Définitions et théorie
Favicon
QA - Comment rédiger un test utile ?
Favicon
Applying integration test on NestJS with Jest and GitHub Actions
Favicon
DRY up RSpec subject defining
Favicon
On testing
Favicon
Um vídeo sobre gems e recursos interessantes que podemos integrar com nossas aplicações rails.
Favicon
🩰 Schedule automated tests; become premier ballet artiste
Favicon
Testing Timer-based Logic in Elixir with Klotho Library
Favicon
[Go] How to work with dates in tests
Favicon
Usando o chat do Bing como um aliado para escrever testes de software
Favicon
When and How to Write End-to-End Tests: A Beginner's Guide to Automated E2E Testing
Favicon
Easy Integration Tests for Event-Driven AWS Architectures with EventScout 📨🔭
Favicon
Fix Symfony tests with PHPUnit 10
Favicon
Is programming in TypeScript simply another excuse not to write test in JavaScript?
Favicon
Mocking Interface with jest-mock-extended
Favicon
Do we must implements unit test just to have coverage?
Favicon
Testing a FastAPI application using Ormar models and Alembic migrations
Favicon
How do you deal with test record leaks?
Favicon
Improve your tests with Assert Object Pattern
Favicon
Laravel how to set app environment during tests

Featured ones: