2

I've have this error on executing tests

PHP Fatal error: Class 'PHPUnit\Framework\TestCase' not found in /vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Test/KernelTestCase.php on line 24

I can solve with this change

use PHPUnit\Framework\TestCase;
...
abstract class KernelTestCase extends TestCase

by

abstract class KernelTestCase extends \PHPUnit_Framework_TestCase

Is a bug or I'm miss some configuration on the version 3.3.8 of Symfony?

Thanks

P.S. differrent of Why, Fatal error: Class 'PHPUnit_Framework_TestCase' not found in ...? the error is not Fatal error: Class 'PHPUnit_Framework_TestCase' not found in ...

  • 2
    You're probably missing the PHPUnit dependency in your vendor folder. Check your composer.json file if it's there. If it's in a `require-dev` list, install it using `composer update --dev` – rickdenhaan Sep 01 '17 at 14:36
  • How are you running the tests from the Symfony root folder? What is the `exact` command? – Alvin Bunk Sep 01 '17 at 16:00

1 Answers1

1

I've can fix the issue. With PHPUnit 5.4.6 the tests works fine, but with PHPUnit 5.1.3 not.

The solutions are

update phpci

or

Add /usr/share/php/PHPUnit/ForwardCompatibility/TestCase.php to the "problematic" server

<?php
/*
 * This file is part of PHPUnit.
 *
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
 *
 * For the full copyright and license information, please view the     LICENSE
 * file that was distributed with this source code.
 */

namespace PHPUnit\Framework;

use PHPUnit_Framework_TestCase;

class TestCase extends PHPUnit_Framework_TestCase
{
}

And add this class to /usr/share/php/PHPUnit/Autoload.php

    ...
$classes = array(
    'phpunit\\framework\\testcase' => '/ForwardCompatibility/TestCase.php',
...

Thanks.

Tokeeen.com
  • 718
  • 7
  • 19