PHP致命错误与Symfony的PHPUnit的3.3.8

问题描述:

我一直有这样的错误上执行测试PHP致命错误与Symfony的PHPUnit的3.3.8

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

我可以

abstract class KernelTestCase extends \PHPUnit_Framework_TestCase 

这种变化

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

解决是一个错误还是我错过了Symfony 3.3.8版的一些配置?

谢谢

P.S.不同的Why, Fatal error: Class 'PHPUnit_Framework_TestCase' not found in ...? 错误不是致命错误:类'PHPUnit_Framework_TestCase'找不到...

+2

您可能缺少供应商文件夹中的PHPUnit依赖项。检查你的composer.json文件是否存在。如果它位于'require-dev'列表中,请使用'composer update --dev'安装它。 – rickdenhaan

+0

如何从Symfony根文件夹运行测试?什么是“确切”命令? –

我可以解决这个问题。 使用PHPUnit 5.4.6,测试可以正常工作,但不适用PHPUnit 5.1.3。

的解决方案是

update phpci 

添加/usr/share/php/PHPUnit/ForwardCompatibility/TestCase.php的 “有问题” 的服务器

<?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 
{ 
} 

而这个类添加到/ usr /共享/ PHP/PHPUnit的/自动加载。 php

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

谢谢。

+0

你应该接受你的答案来解决问题。 – chalasr