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
  • 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 Commented Sep 1, 2017 at 14:36
  • How are you running the tests from the Symfony root folder? What is the exact command? Commented Sep 1, 2017 at 16:00

1 Answer 1

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 <[email protected]>
 *
 * 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.

Sign up to request clarification or add additional context in comments.

1 Comment

You should accept your answer to make the question solved.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.