Error: Class 'Symfony\Component\Config\Resource\BCResourceInterfaceChecker' not found

Error: Class 'Symfony\Component\Config\Resource\BCResourceInterfaceChecker' not found

我将我的应用程序从 symfony 2.8 迁移到 symfony 3.4。

在网络上,它工作得很好。但是当我启动功能测试时,我得到了以下结果:

▶ ./bin/phpunit --filter=testLanguageControllerTestIndexAction                                   
    PHPUnit 5.7.27 by Sebastian Bergmann and contributors.
    
E                                                                   1 / 1 (100%)

Time: 126 ms, Memory: 14.00MB

There was 1 error:

1) Tests\TranslationBundle\Controller\LanguageControllerTest::testLanguageControllerTestIndexAction
Error: Class 'Symfony\Component\Config\Resource\BCResourceInterfaceChecker' not found

/var/www/renault-del/del/src/app/bootstrap.php.cache:3183
/var/www/renault-del/del/src/app/bootstrap.php.cache:2778
/var/www/renault-del/del/src/app/bootstrap.php.cache:2561
/var/www/renault-del/del/src/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Test/KernelTestCase.php:174
/var/www/renault-del/del/src/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Test/WebTestCase.php:34
/var/www/renault-del/del/src/tests/TranslationBundle/Controller/LanguageControllerTest.php:22

ERRORS!
Tests: 1, Assertions: 0, Errors: 1.

顺便说一句,这是我的 composer.json :

"require": {
    "php": "^7.2",
    "course-hero/wse-php": "~2.0.5",
    "doctrine/doctrine-bundle": "^1.6",
    "doctrine/doctrine-fixtures-bundle": "^2.4",
    "doctrine/orm": "^2.5",
    "friendsofsymfony/rest-bundle" : "^2.1",
    "friendsofsymfony/user-bundle": "^2.1",
    "guzzlehttp/guzzle": "^5.3",
    "ijanki/ftp-bundle": "<1.0.3",
    "jms/serializer-bundle" : "^1.1",
    "knplabs/knp-snappy-bundle": "1.6.*",
    "natxet/cssmin": "^3.0",
    "nelmio/api-doc-bundle" : "^3.0",
    "patchwork/jsqueeze": "^2.0",
    "select2/select2": "^4.0",
    "sensio/distribution-bundle": "^5.0",
    "sensio/framework-extra-bundle": "4.0.0",
    "sonata-project/doctrine-orm-admin-bundle": "3.7.0",
    "stof/doctrine-extensions-bundle": "~1.2.0",
    "symfony/assetic-bundle": "^2.8",
    "symfony/monolog-bundle": "^2.8",
    "symfony/swiftmailer-bundle": "^2.3",
    "symfony/symfony": "3.4.*",
    "twig/twig": "^2.12",
    "friendsofsymfony/ckeditor-bundle": "^1.2",
    "white-october/pagerfanta-bundle": "^1.3",
    "liip/imagine-bundle": "^1.9",
    "friendsofsymfony/oauth-server-bundle": "^1.6",
    "psr/container": "^1.0"
},
"require-dev": {
    "friendsofphp/php-cs-fixer" : "@stable",
    "phpunit/phpunit":  "~5.1",
    "symfony/phpunit-bridge": "^5.1"
},

此外,这是从 2.8.03.0.0CHANGELOG

3.0.0

 * removed `ReferenceDumper` class
 * removed the `ResourceInterface::isFresh()` method
 * removed `BCResourceInterfaceChecker` class
 * removed `ResourceInterface::getResource()` method

请问我该怎么办?

终于找到解决办法了。

因此,在从 Symfony 2.8 迁移到 symfony 3.4 之后,您必须移动 bootstrap.php.cache文件从“app”文件夹到“var”文件夹等等,你必须修改路径此文件在 phpunit.xml 配置中。

<!-- http://phpunit.de/manual/4.1/en/appendixes.configuration.html -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd"
         backupGlobals="false"
         colors="true"
         bootstrap="var/bootstrap.php.cache"
>
    <testsuites>
        <testsuite name="Project Test Suite">
            <directory>tests</directory>
        </testsuite>
    </testsuites>

    <php>
        <server name="KERNEL_DIR" value="app/" />
    </php>

    <filter>
        <whitelist>
            <directory>tests</directory>
        </whitelist>
    </filter>
</phpunit>